1 registered members (AbrahamR),
717
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Lite-C Multiple c Files possible?
#436068
01/18/14 11:27
01/18/14 11:27
|
Joined: Jul 2005
Posts: 1,930 Austria
Dark_samurai
OP
Serious User
|
OP
Serious User
Joined: Jul 2005
Posts: 1,930
Austria
|
Dear all, has some of you got Lite-C to compile multiple *.c files like a normal c compiler does? When I remember correctly, this was only possible by including *.c files (with #include "unit1.c"), which is really not a good programming style. If I for example do this: The prototype of PrintMsg() is defined in unit1.h. PrintMsg() is implemented in unit1.c:
#include <acknex.h>
function PrintMsg(STRING* msg)
{
error(msg);
}
This is the very straight forward way how information hiding using multiple *.c files is implemented in standard C. But in Lite-C this leads to a "Empty function called in main" error during runtime. Has anybody got this running, or are multiple *.c files simply not suported by the compiler/linker? Thanks for clarification!
ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)! get free version
|
|
|
Re: Lite-C Multiple c Files possible?
[Re: Dark_samurai]
#436071
01/18/14 12:29
01/18/14 12:29
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
Nope, Lite-C is still just one translation unit.
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Re: Lite-C Multiple c Files possible?
[Re: Superku]
#436074
01/18/14 12:57
01/18/14 12:57
|
Joined: Jul 2005
Posts: 1,930 Austria
Dark_samurai
OP
Serious User
|
OP
Serious User
Joined: Jul 2005
Posts: 1,930
Austria
|
Thanks for your answers @Superku: I also worked with such workarounds, but basicly I miss the information hiding principle of seperate translation units. Maybe JCL is willing to implement that in one of the next updates...
ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)! get free version
|
|
|
Re: Lite-C Multiple c Files possible?
[Re: Dark_samurai]
#436075
01/18/14 14:26
01/18/14 14:26
|
Joined: Mar 2011
Posts: 3,150 Budapest
sivan
Expert
|
Expert
Joined: Mar 2011
Posts: 3,150
Budapest
|
hehh, I just had a shitty Friday because of a wrong script restructurization into .h and .c files... I included first the .h files than the .c files in a main header file that is used by both the editor and the game, no errors, my editor works fine, but some complex rts map decomposition and pathfinding stuff do not want to work again as before... maybe only the .c files should be included in that main file, and the .c files should include the .h files used by it? (header guard or whatever its name is used, you know those ifndef define endif thingie)
Edit: my includes have been fine, I just commented out something that would had been necessary... backups are the best friends.
Last edited by sivan; 01/19/14 16:40.
|
|
|
Re: Lite-C Multiple c Files possible?
[Re: sivan]
#436077
01/18/14 15:41
01/18/14 15:41
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
include guards.
Anyhow, I doubt that multiple translation units will make it into Lite-C. Not so much because of the compiler, but because of the mostly non-existent linker. Why do I think there is no linker? Because Dark_Samurai's code would've never gotten through a linker ever.
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Re: Lite-C Multiple c Files possible?
[Re: WretchedSid]
#436085
01/18/14 22:41
01/18/14 22:41
|
Joined: Jul 2005
Posts: 1,930 Austria
Dark_samurai
OP
Serious User
|
OP
Serious User
Joined: Jul 2005
Posts: 1,930
Austria
|
Not so much because of the compiler, but because of the mostly non-existent linker. Yes this could indeed be the case... Because Dark_Samurai's code would've never gotten through a linker ever. Why? Edit: I guess you ment that the linker has no address for the function because the second *.c file is not compiled (because of the missing feature to compile multiple translation units)? So normally you should get the error during linking, not during runtime...
Last edited by Dark_samurai; 01/18/14 22:44.
ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)! get free version
|
|
|
|