gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > About including libraries in multiple sources [answered]

#177345 - MisterLogan - Fri Apr 27, 2012 8:03 am

When you have two sources, both of them using many parts of libnds, and you #include the library in both sources, what exactly happens? I've heard including is pretty much a copy paste direction for the pre-processor, so does it paste in the library on every source file?

Last edited by MisterLogan on Fri Apr 27, 2012 8:41 pm; edited 1 time in total

#177346 - sverx - Fri Apr 27, 2012 10:23 am

yes, include is like pasting a copy of the included file in the precise point you insert the include directive itself. So beware, only header files (declarations!) should be included!
_________________
libXM7|NDS programming tutorial (Italiano)|Waimanu DS / GBA|A DS Homebrewer's Diary

#177347 - gauauu - Fri Apr 27, 2012 2:58 pm

Instead, like sverx is telling you, you should only #include header files, and to actually use the library, you need to link it in with your source during linking.

#177348 - MisterLogan - Fri Apr 27, 2012 8:15 pm

Alright, thanks.

If you're using functions and such from two or three libnds headers, is it better to just pick out the ones you're using at the time and add them as needed, or just include nds.h? In other words, how much space does nds.h take up in a program?

#177349 - Dwedit - Fri Apr 27, 2012 8:28 pm

nds.h takes up 0 bytes in a program because it is only declarations. The only resource consumed by including more declarations is RAM used while compiling the program.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."

#177350 - MisterLogan - Fri Apr 27, 2012 8:40 pm

Thanks for the help.