Noob question, C

edited April 19 in Help request

Howdy everyone,

I was curious if its okay to write code for use with orx in pure C. I know that orx was written in C. I was also curious if there was a way to launch a new project that creates a C source file instead of one that is in C++. I'm a beginner so I beg your pardon if these questions are of the "wrong" type.

For my newly created project, may I delete the cpp default source file and create another? Is it permissible to change the file extension of a .cpp file to .c in order for my IDE and compiler to recognize that I want to compile C?

Thank you in advance. I appreciate your patience.

I'm using Codeblocks and MinGW on Windows 7.

Comments

  • edited April 19

    Hi @anchorbricks and welcome here!

    You can definitely write pure C code with orx. As you stated yourself orx is entirely written in C and everything is usable in that language.

    Regarding the creation of a new project, the generated code is actually... pure C. :)
    The .cpp extension was chosen so as to make it easier for users to expand on that template using C++, as it seems to be what most people use. That being said, you can simply rename the .cpp extension to .c and then rerun premake4 in the build folder to regenerate the solution/workspace. In your case, using codeblocks, you want to call:
    premake4 codeblocks

    That should be it, you should now have a working C-only base project.

    If you ever decide to use a different IDE, you can regenerate the solution in the same way by calling premake4 <YOUR_IDE>, or check premake4's help if you're not sure of the syntax.

    Note: remember that you need to compile orx itself before being able to compile your project. After that, your project should compile out of the box as the environment variable ORX will point to your orx installation.

  • I just wanted to thank you very much for your timely and thorough response. I appreciate it. Thank you again for laying it plainly. I hope to return with better questions!

  • My pleasure!

    Don't hesitate to come and see us if you have any questions and/or comments, or if you feel stuck at any point.

    We also usually hang out on the chat, feel free to come and join us if you feel like it: https://gitter.im/orx/orx

Sign In or Register to comment.