rswier / c4

C in four functions
GNU General Public License v2.0
9.64k stars 1.42k forks source link

gcc compile error in macos: first parameter of 'main' (argument count) must be of type 'int' #64

Open yinsongbj opened 3 years ago

yinsongbj commented 3 years ago

I got a error when build c4 in macos 10.15

c4.c:333:5: error: first parameter of 'main' (argument count) must be of type 'int'
int main(int argc, char **argv)

My gcc version

gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin20.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Does it not support MacOS and UNIX?

kevintsq commented 2 years ago

It is because of #define int long long. Change int main(int argc, char **argv) to signed main(signed argc, char **argv) works.

andrakis commented 2 years ago

c4 does not know about the type signed, so whilst it compiles with gcc it can't interpret itself anymore.

At the top of the file is a line:

#define int long long

This causes issues on some compilers. Instead try:

#define int long