Question C code compilation

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Hi All,

I wrote simple program to print "Hi how are you" 100,000 times and
compiled on Redhat Linux.

test.c

  main()
    {
       printf("Hi How are you");
         .
         .
         .
       /*Repeated printf for more one hundread thousand times */
    }

then

did #make test
  cc test.c -o test

this command did NOT exit for more than half hour, later I did
control-c to exit.

Please tell me why I can't compile this long code?, what would be the
best approach other than splitting the code.

thanks
kishuri

Re: Question C code compilation
Quoted text here. Click to load it
I know your embedded world is different. However, every embedded
systems do need a compiler and an operating system. This Question
falls under these two sections of embedded systems. Are not there any
better way to generate code, why does it fail or take longer when
compiling huge function like here main()? How long your embedded OS
take to compile this. If fails, how can you fix it? Think over it
before questioning others.
thanks,
kishuri

Re: Question C code compilation
snipped-for-privacy@Watt.COM (Steve Watt) writes:

Quoted text here. Click to load it

Actually this is an  indication  of  extreme  low  resources  on  the
development host. I just tested this on a standard PC running Linux:

    bash$ time gcc -o foo foo.c

    real    0m13.948s
    user    0m12.880s
    sys     0m0.230s

As you can see, it took just 14 seconds to compile your program.

And this is no high-end machine  at  all.  It's  a  standard  AMD  XP
processor at 2083 MHz with 512 MB RAM.


Quoted text here. Click to load it

I have not the slightest idea where you get such a  number  from.  To
build a medium-sized project (U-Boot) with some 350k+ lines of C code
(_not_  counting  the  header and assembler files) takes less than 20
seconds on an even slower machine (AMD Athlon at 1400 Mhz).

Your number is approx. 600 times too big!


Wolfgang Denk

--
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88   Web: www.denx.de
We've slightly trimmed the long signature. Click to see the full one.

Site Timeline