Sujet : Re: question about linker
De : thiago.adams (at) *nospam* gmail.com (Thiago Adams)
Groupes : comp.lang.cDate : 26. Nov 2024, 20:11:45
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vi56hi$3ie0o$2@dont-email.me>
References : 1
User-Agent : Mozilla Thunderbird
On 26/11/2024 15:35, Thiago Adams wrote:
(I think I know the answer but I would like to learn more.)
I am using C89 as "compiler backend intermediate language".
I want a very simple output that could facilitate the construction of a simple C89 compiler focused on code generation.
Another question is.. does the compiler cares about function type when calling a function or this is just an information to avoid programmers mistakes?
Consider this code:
int main() {
strcmp("a", "b");
}
It compiles in -std=c89
Now changing to -std=c99 -std=c11 it gives:
error: implicit declaration of function 'strcmp'
Then adding:
int strcmp();
int main() {
strcmp("a", "b");
}
it works in C99 / C11
I think in C23 empty parameter list means no args, while in the previous versions (void) means no args.
Considering that in previous versions of C we could call a function without its signature I think the compiler only needs the caller side. (of course I am not considering programmer mistakes)
So, I think one extra simplification for small compilers is to ignore function parameters.