4 ms·
I grabbed this when it was originally published, but somehow the file name I have is different from the one in this article. Mine is called "carol.c" and I jus
by anonymousiam 3y ago
I grabbed this when it was originally published, but somehow the file name I have is different from the one in this article. Mine is called "carol.c" and I just compiled and ran it on a modern system. The compiler spat out the following warnings:
gcc -o carol carol.c
carol.c:2:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
2 | main(t,_,a )
| ^~~~
carol.c: In function ‘main’:
carol.c:2:1: warning: type of ‘t’ defaults to ‘int’ [-Wimplicit-int]
carol.c:2:1: warning: type of ‘_’ defaults to ‘int’ [-Wimplicit-int]
- sebtron 3y agoSurprisingly few warnings, and all on the same line!
- rwmj 3y agoGCC 14 won't permit implicit int any more ... https://fedoraproject.org/wiki/Changes/PortingToModernC#Removal_of_implicit_int https://fedoraproject.org/wiki/Changes/PortingToModernC#Remo...
- darknavi 3y agoGood. It's almost as bad as not returning a value from a function being a warning and not an error.
- bonzini 3y agoJust compile with -std=c89
- anonymousiam 3y agoI guess I got lucky then. This Ubuntu 23.10 install has gcc 13.2.0-4ubuntu3 installed from the repo. Given that the code is pre-ANSI C, and that it won in the category of "Least likely to compile successfully", it's surprising that there are no other issues. I wouldn't normally run such a radioactive distro, but this laptop is so new that there is no LTS distro that works on it. (AMD Ryzen 7 PRO 7840U w/ Radeon 780M Graphics)
- ramesh31 3y agoThe issue is calling xmas() in main before it's defined. Compiling with GCC on macOS gives the error: xmas.c:16:5: error: call to undeclared function 'xmas'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] xmas(2, 2, ""); Moving main() to the bottom compiles and executes with the proper output.
- lights0123 3y agoReal GCC or Apple’s clang symlinked to gcc?