This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compile C program without main function

Other Parts Discussed in Thread: HALCOGEN

Hi support,

I need to compile a C program which contains a few routines (without main() function). It means that I would have many entry points. The problem is that I can't compile a C program without a main() function. I've been looking for some compiler options for gcc, but I did'nt find anything that could help me. 

How can I do that?

I'm working with Code Composer Studio v6.1 and HALCoGen v4.05.02

Regards,

Fabio

  • Before I can answer, I need a better idea of what problem you want to solve.  Don't worry about describing any method you might use to solve the problem.  At a high level, what do you want your system to do?

    One guess to consider ...You might have a system that needs to respond to a few different kinds of interrupts.  Systems like that use the main routine to do nothing but initialize things.  The last thing main does is call a function that puts the system in an idle loop, or some sleep mode, or something like that.  Now the system is ready to respond to the interrupts as they occur.

    Thanks and regards,

    -George

  • Hi, George, thanks for your reply.

    What I really want to do is my own JTAG programmer. So, in order to program the flash, I would need at least two routines (i.e firmware): one for erasing, and other for programming the flash. I want to have full control about passing parameters, return values, execution (i.e pointing the PC to the routine entry point). So, my idea is try to compile the routines (without main() function), and finally obtain the .HEX file that works as my firmware.

    Regards,

    Fabio.

  • Consider building two executable .out files, and then combining them using the technique described in this wiki article.

    Thanks and regards,

    -George