Dealing with larger codebase / includes


#1

Hello,

After a while off, I want to start investigating some module ideas I have. However, most of them will be fairely 'large' and I was wondering what it the status of using #includes in objects. Ideally I would like to have all the implementation in external classes and only 'bridge' the class in an axoloti module. Last time I tried I didn't find a way of referring to external classes (maybe this was only a wrong path issue ?) but It'd be cool to have a little pointer on the topic. This would also allow me to re-use classes across different modules.

Thanks in advance !
/M


#2

In current version all you can do is include files
( see my push example in community library)

In the next release I've implemented something called ''modules' which allows separate compileable units.

The reason for this, is the namespace needs to be managed to ensure object developers don't break other developers objects ( inadvertently)

Of course for private code you could also start hacking makefiles


#3

Thanks. Can you tell me where I need to put the includes for the compiler to find them ?


#4

you can include a header file from the object (relative to objects location), and then you can do includes in that relative to that header files (as with normal C)

what you can't do add paths to the include path.

obviously, this extends beyond include paths, since to have separate C files, you would also need to be able to compile these or add libraries to the link path... which is what the new modules stuff is all about.
I refer you to my push object where you can see what I did to workaround this.

basically my objective was to structure the code, such that when we developed 'compile units' I would be able to transition the code simply.


#5

Thanks a lot.
In the mean time I can use templates and header only code :smiley: I'll try and report if anything weird comes up


#6

the main thing to be careful of is by default the compiler will inline all code that's brought in via headers (this is normal compiler behaviour) , which this can huge code sizes. you will need to explicitly tell the compiler not to inline the code... choosing which , of course depends on your use-case, and you have to take care as it will impact performance... again, my push object shows how to do this.
if you don't do this you will run out of memory in the code segment for anything other than pretty trivial code.