Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

你好,关于代码编译问题 #1

Open
ExcaliburEX opened this issue Oct 10, 2018 · 5 comments
Open

你好,关于代码编译问题 #1

ExcaliburEX opened this issue Oct 10, 2018 · 5 comments

Comments

@ExcaliburEX
Copy link

代码好像有点问题,在makeclear()函数那里,下面是出错警报,有空看一下呗:smile:

||=== 构建文件: "无目标" 在 "无项目" 中 (编译器: 未知的) ===|
C:\Users\acer\Downloads\Minesweeper-master\Minesweeper-master\main function.c|522|error: conflicting types for 'makeclear'|
C:\Users\acer\Downloads\Minesweeper-master\Minesweeper-master\main function.c|308|note: previous definition of 'makeclear' was here|
C:\Users\acer\Downloads\Minesweeper-master\Minesweeper-master\main function.c||In function 'randomchoice':|
C:\Users\acer\Downloads\Minesweeper-master\Minesweeper-master\main function.c|677|error: expected expression before 'int'|
C:\Users\acer\Downloads\Minesweeper-master\Minesweeper-master\main function.c||In function 'main':|
C:\Users\acer\Downloads\Minesweeper-master\Minesweeper-master\main function.c|782|error: expected expression before 'int'|
C:\Users\acer\Downloads\Minesweeper-master\Minesweeper-master\main function.c|783|error: expected expression before 'int'|
C:\Users\acer\Downloads\Minesweeper-master\Minesweeper-master\main function.c|784|error: expected expression before 'int'|
C:\Users\acer\Downloads\Minesweeper-master\Minesweeper-master\main function.c|785|error: expected expression before 'int'|
C:\Users\acer\Downloads\Minesweeper-master\Minesweeper-master\main function.c|786|error: expected expression before 'int'|
C:\Users\acer\Downloads\Minesweeper-master\Minesweeper-master\main function.c|888|error: expected expression before 'int'|
C:\Users\acer\Downloads\Minesweeper-master\Minesweeper-master\main function.c|889|error: 'group' undeclared (first use in this function)|
C:\Users\acer\Downloads\Minesweeper-master\Minesweeper-master\main function.c|889|note: each undeclared identifier is reported only once for each function it appears in|
C:\Users\acer\Downloads\Minesweeper-master\Minesweeper-master\main function.c|907|error: 'groupsucceed' undeclared (first use in this function)|
C:\Users\acer\Downloads\Minesweeper-master\Minesweeper-master\main function.c|907|error: 'grouptime' undeclared (first use in this function)|
C:\Users\acer\Downloads\Minesweeper-master\Minesweeper-master\main function.c|907|error: 'groupclick' undeclared (first use in this function)|
C:\Users\acer\Downloads\Minesweeper-master\Minesweeper-master\main function.c|907|error: expected expression before 'int'|
C:\Users\acer\Downloads\Minesweeper-master\Minesweeper-master\main function.c|939|error: expected expression before 'int'|
C:\Users\acer\Downloads\Minesweeper-master\Minesweeper-master\main function.c|940|error: expected expression before 'int'|
C:\Users\acer\Downloads\Minesweeper-master\Minesweeper-master\main function.c|941|error: expected expression before 'int'|
||=== 构建 失败: 16 error(s), 0 warning(s) (0 分, 0 秒) ===|

@SnowOnion
Copy link

  1. 我看代码发现有两个 makeclear 函数定义,308 行 void makeclear(int i,int j),522 行 int makeclear()

  2. 有这样的写法:int(click)。哪个 C 标准允许这样类型转换了吗= =、?

我试图在 macOS 用 clang 编译的时候,报的错和楼主类似。然而用 clang++ 能编译通过并运行。然而用 clang -std=* 其中 * 取 c11 c89 c90 c99 都不能编译通过。

所以队长是用的啥编译器(以及版本和参数)呢?

附:

➜  Jiangzemin1926-Minesweeper git:(master) ✗ clang --version
Apple LLVM version 10.0.0 (clang-1000.11.45.2)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
➜  Jiangzemin1926-Minesweeper git:(master) ✗ clang++ --version
Apple LLVM version 10.0.0 (clang-1000.11.45.2)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

@ExcaliburEX
Copy link
Author

  1. 对,后来也发现了函数重名,无参数的makeplace就用了一次改一下就可以。
  2. 然后取整函数确实没看懂...一般编译器都过不了
  3. 主函数的一系列数组定义完全可以放在一开始,程序会自动将这些数组初始化。

@Sakuranosai
Copy link

求教楼上的各位,编译问题解决了吗?我遇到了和你们一样的问题:重复定义makeclear,int强制转换

@ExcaliburEX
Copy link
Author

求教楼上的各位,编译问题解决了吗?我遇到了和你们一样的问题:重复定义makeclear,int强制转换

年代久远,不怎么记得了,你把makeplace改个名字,相应调用的地方也改一下,取整函数改成通用的语法,然后再试试。不行的话,再把数组定义全放到主函数前面。

@SnowOnion
Copy link

求教楼上的各位,编译问题解决了吗?我遇到了和你们一样的问题:重复定义makeclear,int强制转换

建议找个别的扫雷,,,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants