stolk/imcat

The project is not built using Clang (MacOS, M1).

Vadimatorik opened this issue · 3 comments

% make 
cc -D_POSIX_C_SOURCE=2 -std=c99 -Wall -g -o imcat imcat.c -lm
imcat.c:87:4: error: implicitly declaring library function 'snprintf' with type 'int (char *, unsigned long, const char *, ...)' [-Werror,-Wimplicit-function-declaration]
                        snprintf( tripl, sizeof(tripl), "%d;%d;%dm ", r,g,b );
                        ^
imcat.c:87:4: note: include the header <stdio.h> or explicitly provide a declaration for 'snprintf'
1 error generated.
make: *** [imcat] Error 1

My envairement:

% 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 13.0.0 (clang-1300.0.29.30)
Target: arm64-apple-darwin21.3.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
% g++ -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 13.0.0 (clang-1300.0.29.30)
Target: arm64-apple-darwin21.3.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Same here.
But you've already know this is something wrong with clang, there is nothing helpful with gcc version info.
My Solution:

change Makefile , let imcat build without those args: cc -g -o imcat imcat.c -lm

Not much sure what is really wrong there, this just works.

clang version: Apple clang version 13.1.6

stolk commented

stdio.h is the first included file. I have no idea why MacOS clang can't find it. I'm kinda stomped on this.

stolk commented

Can you try adding -D_DARWIN_C_SOURCE to the Makefile?