Skip to content

Instantly share code, notes, and snippets.

@DocBohn
Last active June 23, 2025 19:07
Show Gist options
  • Save DocBohn/525edcf8cf9912f9951af7d968751e09 to your computer and use it in GitHub Desktop.
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
#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