Multi-file program in NXC
-
- Posts: 103
- Joined: 29 Sep 2010, 17:14
- Location: US
Multi-file program in NXC
I've been making attempts to create a multi-file program in NXC, but I have been having quite a bit of difficulty. I'm curious, what are the basics to tell the NBC compiler to treat all files as one program?
fuzzball27 >>-->
Re: Multi-file program in NXC
do you mean:
including libraries to a main program by e.g.:
#include "xyz.h"
#include "abc.nxc"
?
including libraries to a main program by e.g.:
#include "xyz.h"
#include "abc.nxc"
?
-
- Posts: 103
- Joined: 29 Sep 2010, 17:14
- Location: US
Re: Multi-file program in NXC
Yes. That's what I'm asking about. The problem that I have is that the included file can't be compiled... also, the compiler keeps saying that #endif is an invalid preprocessor command.
fuzzball27 >>-->
Re: Multi-file program in NXC
why #endif?
maybe you should post the code or at least a snippet...
maybe you should post the code or at least a snippet...
-
- Posts: 103
- Joined: 29 Sep 2010, 17:14
- Location: US
Re: Multi-file program in NXC
I was using #ifndef to avoid multiple definitions. I deleted the code because it was very small. It was something like this:
The main task was something like this:
Code: Select all
#ifndef _SOURCECODE
#define _SOURCECODE
//subroutines...
#endif
Code: Select all
#include "Sourcecode.nxc"//The name of the previous code file.
task main() {
//code...
}
fuzzball27 >>-->
Re: Multi-file program in NXC
that should have been correct, it's the same way I use it:
I assume there was a typo...
Code: Select all
// file: stdlib.h
#ifndef _STDLIB_H_
#define _STDLIB_H_
//******************************************************************************
// code
//******************************************************************************
#endif // _STDLIB_H_
-
- Posts: 103
- Joined: 29 Sep 2010, 17:14
- Location: US
Re: Multi-file program in NXC
How do I compile the source code? The compiler complains about there not being a main task.
fuzzball27 >>-->
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: Multi-file program in NXC
I do it by throwing in a dummy task main(){}, and then just leave it uncommented to compile. Often I will use task main as a test task for functions that the library supports, and then comment it out whenever I am done testing (so that when I #include it in another program, it doesn't complain about two task mains).
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
Re: Multi-file program in NXC
I do it other way round:
I'm programming in one whole file, and when I think I will need one function or the other further on for other projects, I copy them into my existing stdlib.h and nxcio.h libraries. Debugging multi-file projects is not easy in Bricxcc.
But I agree, it would be desirable if one could have code-highlighting and test-compiling also of libraries / header files ( *.h) for syntax checking even without having a task main, in case there have been made some mistakes accidentally when having changed the code subsequently.
I'm programming in one whole file, and when I think I will need one function or the other further on for other projects, I copy them into my existing stdlib.h and nxcio.h libraries. Debugging multi-file projects is not easy in Bricxcc.
But I agree, it would be desirable if one could have code-highlighting and test-compiling also of libraries / header files ( *.h) for syntax checking even without having a task main, in case there have been made some mistakes accidentally when having changed the code subsequently.
-
- Posts: 103
- Joined: 29 Sep 2010, 17:14
- Location: US
Re: Multi-file program in NXC
How do you compile your final product all together?mattallen37 wrote:I do it by throwing in a dummy task main(){}, and then just leave it uncommented to compile.
fuzzball27 >>-->
Who is online
Users browsing this forum: No registered users and 1 guest