Are long single C source files unreliable?

This is a discussion on Are long single C source files unreliable? within the C Programming forums, part of the General Programming Boards category; Hi, I'm needing an experienced programmers opinion about gcc and writing c programs. I've written a fairly large program 11000 ...

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    25

    is there a limit to what gcc can handle?

    Hi,
    I'm needing an experienced programmers opinion about gcc and writing c programs. I've written a fairly large program 11000 + lines of code in a single program - a single file.
    It compiles and runs fine on one Linux server yet on another Unix server, while it compiles fine, when executed it seems to stuble over the simplest areas of code that it should recognise - there is no error in the code - but for some reason the executable won't run - very peculair behavior.
    Does gcc have trouble dealing with very large files or something? Or is it the different system the problem here? I just don't get it ! For example in the main function if I omit the following line, which initialises a global variable (struct variable)

    input.is[0]='\x00';

    the script will work - now what the hell is going on here? Its the same for certain other spots in the code - it just doesn't seem to like it for some reason when its perfectly correct code.
    Would breaking the code down into smaller files and linking during compiling likely help? Does this improve the chances of long areas of code working more reliably?

    Has anyone experienced this sort of problem before and how did you get around it,

    Cheers, your help and words of wisdom will be much appreciated,

    Brett

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    25

    Are long single C source files unreliable?

    Hi,
    I'm needing an experienced programmers opinion about gcc and writing c programs. I've written a fairly large program 11000 + lines of code in a single program - a single file.
    It compiles and runs fine on one Linux server yet on another Unix server, while it compiles fine, when executed it seems to stuble over the simplest areas of code that it should recognise - there is no error in the code - but for some reason the executable won't run - very peculair behavior.
    Does gcc have trouble dealing with very large files or something? Or is it the different system the problem here? I just don't get it ! For example in the main function if I omit the following line, which initialises a global variable (struct variable)

    input.is[0]='\x00';

    the script will work - now what the hell is going on here? Its the same for certain other spots in the code - it just doesn't seem to like it for some reason when its perfectly correct code.
    Would breaking the code down into smaller files and linking during compiling likely help? Does this improve the chances of long areas of code working more reliably?

    Has anyone experienced this sort of problem before and how did you get around it,

    Cheers, your help and words of wisdom will be much appreciated,

    Brett

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    I can't speak for GCC, but with some old compilers there is a segment size that you had to deal with. This applied also to the amount, if I remember correctly, of lines of code you could end up with in a single file. (16K or something?) I don't remember the specifics.

    For purely organization's sake, you may want to split that up into smaller files, just so it's easier to find what you're looking for.

    Quzah.
    Hope is the first step on the road to disappointment.

  4. #4
    B26354 Deckard's Avatar
    Join Date
    Jan 2002
    Posts
    633
    Sorry BJ, but I have to suspect a typo in your code. After all, gcc compiled the Linux kernel and all the supporting applications that came with your OS. Some of these are far larger than 11k lines of code.

    When a compiler reports an error at (let's say) line 766, yet line 766 is a perfectly legal statement, start scanning backwards. You may find a missing (or extra) semi-colon or brace that confuses the compiler. If you still believe it is gcc and not your code, try using a different compiler.
    I'm curious to know how that turns out.

    Cheers,
    Jason Deckard

  5. #5
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    I've had problems using GCC and large files, got an linker error. Solved this by splitting the files, it helped.

  6. #6
    Registered User biosx's Avatar
    Join Date
    Aug 2001
    Posts
    230
    I think it is good practice anyway to split a program into multiple source files based on categorical concepts. You should try splitting it up and then running it again on multiple systems and see if it makes a difference.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Inserting a swf file in a windows application
    By face_master in forum Windows Programming
    Replies: 12
    Last Post: 05-03-2009, 11:29 AM
  2. Global arrays shared between multiple source files
    By mike_g in forum C Programming
    Replies: 4
    Last Post: 08-14-2008, 06:29 PM
  3. Working with multiple source files
    By abh!shek in forum C Programming
    Replies: 17
    Last Post: 06-03-2008, 11:23 AM
  4. Linking header files, Source files and main program(Accel. C++)
    By Daniel Primed in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2006, 10:46 AM
  5. Replies: 0
    Last Post: 03-25-2002, 03:02 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21