c - Why there is no error after excluding standard library? -


as beginner in c experimenting something, excluded standard library <stdio.h> , still there no error. can explain it?

here sample code:

main() {     printf("hello, world!\n"); } 

this program working same or without library. why?

tl;dr -- you're excluding header file, not standard library.


if exclude header file function having forward declaration, you'll receive warning sure mentioning "implicit declaration" of function.

in case, (invalid per latest standards), function assumed return int , no check on number of parameters passed there.

however, default, generated object file source linked default c library libc has function definition present. in case, function return type matches implicit case, linker happily links object files together.

so, finishes linking , works same.

that said, main() should int main(void), @ least conform standards.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -