A
Angus
My understanding is that #including a header file is a convenience -
to tell the compiler that this file contains a list of some functions
used in this source file. Is that correct?
So eg to copy a file I can do this:
#include <string.h>
int main(){
char dest[512] = {0};
char* src = "Hello world";
strcpy(dest, src);
return 0;
}
But on that reckoning I should also be able to do this:
char* strcpy(char *, const char *);
int main(){
char dest[512] = {0};
char* src = "Hello world";
strcpy(dest, src);
return 0;
}
ie with no #include. On my compiler this compiles but it does not
link. It is as if somehow the #include of the <string.h> file somehow
is passing this information to the linker? Is that possible?
If so is this compiler specific or a standard linker feature?
So I need a parameter to pass to the linker to pass the library which
contains strcpy? (if I do this without #including header).
to tell the compiler that this file contains a list of some functions
used in this source file. Is that correct?
So eg to copy a file I can do this:
#include <string.h>
int main(){
char dest[512] = {0};
char* src = "Hello world";
strcpy(dest, src);
return 0;
}
But on that reckoning I should also be able to do this:
char* strcpy(char *, const char *);
int main(){
char dest[512] = {0};
char* src = "Hello world";
strcpy(dest, src);
return 0;
}
ie with no #include. On my compiler this compiles but it does not
link. It is as if somehow the #include of the <string.h> file somehow
is passing this information to the linker? Is that possible?
If so is this compiler specific or a standard linker feature?
So I need a parameter to pass to the linker to pass the library which
contains strcpy? (if I do this without #including header).