0

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

  • 2
    can you please edit your question to include the output of ls-l ~/Documents – Wayne_Yux Dec 29 '15 at 15:25
3

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 -x option).

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.