Registered Member
|
Hi, all!
I'm relatively new to C coding. With Visual Studio C# I haven't had this issue and the Arduino IDE doen't deal with .c and .h files natively. Well, now I started a project in the KDevelopment IDE and after some growing of the main.c I decided to separate the source into some smaller files each related more to some specific theme. Problem a) might be some kind of bug in the IDE: I added a new file via the menu "File - New Strg-N" and put "/* test.c */" into the first line. Then I selected "File - Save Strg-S" from the menu and the IDE crashed with an error and the option to "restart" it. After the restart (deleting cache selected as an option while restarting) there was no sign of life from the IDE any more and I had to kill it. The next restart showed no problems any more and I was not able to reproduce that error again. Actually I create files with touch xxx.c from a console window and open it in the IDE then. Problem b) is not KDevelopment specific, but you might give me a hand with it: What is the best (aka correct) way to include sub sources from the main source? Right now I have: main.c with a line #include "main.h" and #include "xlib_utilities.c" et al main.h with include <stdio.h> et al plus the prototype int main( int argc, char *argv[] );, whole file surrounded by a #ifndef construct to prevent doubled import. Would it be better to include the e.g. xlib_utilities.c from there?
Then there is the xlib_utilities.c with a first line of #include "xlib_utilities.h". That one has e.g. #include <X11/Xlib.h> and other includes, a few #define, variable declarations and prototypes, again surrounded by #ifndef. Is it correct to include the .c file which itself includes the .h file? Or should I include the .h file? Have I then to include the .c from there?
Thanks for advice Michael |
Registered users: bartoloni, Bing [Bot], Google [Bot], Sogou [Bot], Yahoo [Bot]