I've started introducing some C++ modules to my code project (scientific number-crunching), where it's convenient to do so, and have been following the instructions at for mixing code.
A few things are niggling me, mostly trivial, but here goes...
(1) [Annoying niggle] I've been modifying header files for C modules by surrounding them with,
Unfortunately including the line [tt]extern "C" {[/tt] causes all editors I've encountered to want to indent everything that follows. Any way to stop this? I considered just defining a couple of things, [tt]#define BEGINexternC ...[/tt] and [tt]ENDexternC[/tt], but is there something simpler I can do?
(2) [tt]bool[/tt] and [tt]_Bool[/tt]. In C code I've used the [tt]_Bool[/tt] type because I don't particularly feel the need for the convenience of calling things "true" or "false". What's wrong with just saying 1 and 0? However, C++ seems to really dislike any sign of _Bool, even in header files surrounded by [tt]extern "C" { ... }[/tt]. So I presume just switching [tt]_Bool[/tt] to [tt]bool[/tt] and including [tt]stdbool.h[/tt] is the way out? Any issues I should be aware of?
(3) [Compiler question.] Is it necessary to use the different commands [tt]g++[/tt] and [tt]gcc[/tt] when compiling C++ and C respectively, or will [tt]gcc[/tt] sort this out by itself? So far I've worked by defining two different compilers in my Makefiles,
Many thanks!
A few things are niggling me, mostly trivial, but here goes...
(1) [Annoying niggle] I've been modifying header files for C modules by surrounding them with,
Code:
#ifdef __cplusplus
extern "C" {
#endif
/* Header stuff */
#ifdef __cplusplus
}
#endif
(2) [tt]bool[/tt] and [tt]_Bool[/tt]. In C code I've used the [tt]_Bool[/tt] type because I don't particularly feel the need for the convenience of calling things "true" or "false". What's wrong with just saying 1 and 0? However, C++ seems to really dislike any sign of _Bool, even in header files surrounded by [tt]extern "C" { ... }[/tt]. So I presume just switching [tt]_Bool[/tt] to [tt]bool[/tt] and including [tt]stdbool.h[/tt] is the way out? Any issues I should be aware of?
(3) [Compiler question.] Is it necessary to use the different commands [tt]g++[/tt] and [tt]gcc[/tt] when compiling C++ and C respectively, or will [tt]gcc[/tt] sort this out by itself? So far I've worked by defining two different compilers in my Makefiles,
Code:
CC = gcc
CppC = g++
Many thanks!