Last active
June 23, 2025 19:07
-
-
Save DocBohn/525edcf8cf9912f9951af7d968751e09 to your computer and use it in GitHub Desktop.
Before C23, and empty parameter list in a declaration provides no information about the parameter list; this code should not compile after C23
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <stdio.h> | |
void put_in_register(int i); | |
//int read_from_register(void); // conflicting type with definition | |
int read_from_register(); // incomplete declaration | |
int main(int argc, const char *argv[]) { | |
if (argc < 2) { | |
fprintf(stderr, "Provide a number as a command line argument\n"); | |
exit(-1); | |
} | |
int j = atoi(argv[1]); | |
put_in_register(j); | |
int k = read_from_register(); | |
printf("%d\n", k); | |
} | |
void put_in_register(int i) {} | |
int read_from_register(int i) { | |
return i; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment