Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AndrewAMD, 7th_zorro, ozgur, Quad), 841 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
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 Offline OP
Serious User
Dark_samurai  Offline 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:

Code:
#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 Offline
Expert
WretchedSid  Offline
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: WretchedSid] #436072
01/18/14 12:50
01/18/14 12:50
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
What I normally do is I write #include "unit1.c" at the bottom of the *.h file which allows me to only include the *.h file in my main program and use that file for reference. I know that's not exactly what you are looking for but I think it's better than just using *.c files.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
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 Offline OP
Serious User
Dark_samurai  Offline OP
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
Thanks for your answers wink

@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 Offline
Expert
sivan  Offline
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.

Free world editor for 3D Gamestudio: MapBuilder Editor
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 Offline
Expert
WretchedSid  Offline
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 Offline OP
Serious User
Dark_samurai  Offline OP
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
Quote:
Not so much because of the compiler, but because of the mostly non-existent linker.


Yes this could indeed be the case...

Quote:
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

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1