This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Regarding startup file

Hello, I written simple c program mention below by selecting the lpc2148 chip but not include its startup file in the project. when i run it will go in infinite loop. I also put the break point but i think its not coming to that execution line. Is it necessary to include startup file?
void main()
{ int a=2,b=3,c; c= a+b;
}

Parents Reply Children
  • I wouldn't see it so much a bug as a limitation. Another limitation is that many processors don't manage to initialize any global variables so you need to supply a startup file to zero global variables that isn't given an explicit initialization in the source code. And the startup code must also figure out a way to give specific start values for the global variables that needs that.

    In short, there are lots of functionality the startup files have to help with, to make sure that the processor can reach main() in a way that is compatible with the C language standard.

    Remember that a processor is normally not designed for a specific programming language. So there are different requirements when starting a C program or a Pascal program.

    The startup file is the workaround "glue" that helps making the processor compatible with a specific programming language. If you write programs in assembler instead of an high-level languaeg, then the processor can manage to run the program directly, without any helper code.