鱼C论坛

 找回密码
 立即注册
查看: 3073|回复: 4

[已解决]函数声明的作用域

[复制链接]
发表于 2022-11-15 22:30:54 | 显示全部楼层    本楼为最佳答案   
本帖最后由 jackz007 于 2022-11-15 22:32 编辑

          确实,VC都可以,但是 gcc 不灵
        【tdm-gcc 5.1.0】:
  1. D:\[00.Exerciese.2022]\C>g++ -o x x.c
  2. x.c:3:11: error: '::main' must return 'int'
  3. void main()
  4.            ^
  5. x.c: In function 'int test()':
  6. x.c:15:18: error: 'max' was not declared in this scope
  7.          c=max(a,b);
  8.                   ^

  9. D:\[00.Exerciese.2022]\C>
复制代码

        【vc6.0】:
  1. D:\[00.Exerciese.2022]\C>cl x.c
  2. Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86
  3. Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

  4. x.c
  5. Microsoft (R) Incremental Linker Version 6.00.8447
  6. Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

  7. /out:x.exe
  8. x.obj

  9. D:\[00.Exerciese.2022]\C>
复制代码

        【vc9.0】:
  1. D:\[00.Exerciese.2022]\C>cl x.c
  2. 用于 80x86 的 Microsoft (R) 32 位 C/C++ 优化编译器 15.00.30729.01 版
  3. 版权所有(C) Microsoft Corporation。保留所有权利。

  4. x.c
  5. Microsoft (R) Incremental Linker Version 9.00.30729.01
  6. Copyright (C) Microsoft Corporation.  All rights reserved.

  7. /out:x.exe
  8. x.obj

  9. D:\[00.Exerciese.2022]\C>
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-10-14 05:02

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表