i wrote a code on codeblocks, compiled it and it created a executable file but didn't run. xterm is showing permission denied. but when i saved the program with .cpp extension it worked well and created a file with *.o extention. Can anyone please describe why's this happening and what's c preprocessor?? Thanks in advance. permission denied showing
The underlying compiler (usually
gcc) uses filename extension to determine what kind of code the file contains and thus how to compile it (although this can be overridden using the
In this case, you appear to have saved what appears to be C code with the filename
untitled, which the compiler doesn't know how to handle. In fact, it looks like the CodeBlocks IDE doesn't know how to handle it either, so is defaulting to attempting to execute it as a shell script.
When you give your file a
.cpp extension the IDE and compiler treat it as C++ code and the file is successfully compiled.
Note that a
.o file is an object code file rather than an executable program: that is essentially the difference between compiling and building.