Author Topic: SDL and cpp project.  (Read 4212 times)

Offline phR689

  • Single posting newcomer
  • *
  • Posts: 6
SDL and cpp project.
« on: April 15, 2012, 04:47:02 pm »
Hello
When i create a new SDL project, C::B creates a "main.cpp" file.

But, i want to create a C SDL project.
Can you help me?

My C::B release is 10.05 and runs on a GNU/Linux Ubuntu platform

Regards
Thanks

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7790
    • My Best Post
Re: SDL and cpp project.
« Reply #1 on: April 15, 2012, 06:08:40 pm »
Save "main.cpp" as "main.c"
Add "main.c" to project
remove "main.cpp" from project.

Fix the compiler errors in "main.c"; the simplest fix is adding "#include <stdbool.h>"
Code
#ifdef __cplusplus
    #include <cstdlib>
#else
    #include <stdlib.h>
    #include <stdbool.h>
#endif

Save the project as a template. (Note: I have never done this step myself.)
Use the template for future  C SDL Projects.

Tim S.
« Last Edit: April 15, 2012, 06:14:07 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline phR689

  • Single posting newcomer
  • *
  • Posts: 6
Re: SDL and cpp project.
« Reply #2 on: April 15, 2012, 07:03:03 pm »
hi Tim,

Thanks a lot for your help.

I'll work with this template from now on.

Philippe