LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   is this ansi C? (https://www.linuxquestions.org/questions/programming-9/is-this-ansi-c-762658/)

smeezekitty 10-17-2009 06:13 PM

is this ansi C?
 
first this is not homework just had a personal question
is this code ANSI C?
Code:

#undef DOS_WIN
#define UNIX
int main(){
void print_hello_world(){
printf("Hello world");
#ifdef UNIX
printf("\n");
#endif
#ifdef DOS_WIN
printf("\r\n");
#endif
}
print_hello_world();
}


neonsignal 10-17-2009 06:46 PM

No, you can't have nested function definitions. If you specify '-pedantic', gcc will give you the appropriate warning. (Incidentally, you also need a prototype for the printf).

smeezekitty 10-17-2009 06:59 PM

thats what i thought


All times are GMT -5. The time now is 07:44 PM.