Q: I really hate IRC sometimes.
u003cmeu003e so what is the difference between drafting a master file that contains # a bunch of others, versus the composition of a bunch of object files and linking them together and what all not? 977 503 977 503 u003cmeu003e u003cguyu003e the link you elaborate? U003cguyu003e 977,503 in one case there is connection between the files in the other case there not
u003cmeu003e I do not understand what “link” in this context 977.503 u003cguyu003e you used the word linking above, link is a noun form of it.
u003cmeu003e Guy: I do not understand what the implications of that, although his. is still not a completely random difference
u003cguyu003e you would like to explore what relationship concerns, somewhat
Gee, thanks for the help. i/expressions/rolleye.gif
So I tried to read more about the link, and Im not really learning anything. I really understand how it works. So why is most software to compile an object for each source file, and then connecting, rather than just including the files?
Data Recovery Software – Deleted File Recovery – 75% Commissions
Re:Compiling time doesn't decrease, in fact, it probably increases. But, if you are using something like make (or MSVC++) it will only rebuild the changed files, and so then it does save compilation time.
Some compilers are stupid and if a function is in a c file and not used, it is still compiled. Most linkers are not, though, and only link what is being used. However, that probably isn't an issue for modern compilers on x86.
File Crumble-Powerful File Shredding No File Recovery!
Re:I think the most important reason being compiling time.
The second reason is if you break down your programs in modules, you can use those pre-compiled modules for other projects, other programming language
Wholesale Sources.
Re:Originally posted by: guy
IRC is more a conduit of tripe than knowledge. Most of the people that hang out supplement their lack of knowledge via insults, banning you because they're an op, etc. I don't believe I've been able to elicit a conversation worthy of note on IRC in years.
There are small pockets of really great people on IRC, and I tend to keep within those small groups, since the majority of IRC is pretty awful. This one person may have been obtuse on purpose though, since he seemed to have written me off as unintelligent when a while back I refused to participate in stupid games when he asked me to answer the question of "what is a computer"? i/expressions/rolleye.gif It's a million things, STFU and make your point, if you even have one. He's one of those people that *is* smart, but has allowed it to get to his head, and in turn, has turned into a dumbass. The thing that drives me nuts is that people like that don't even realize that they're being stupid.
Oh, and I think it works out best when *no one* has ops, and *extremely* few people have access to chanserv or whatever to get them. People can be jerks all they want, but if they can't kick and/or ban you, then it doesn't really matter.
Anyway, moving on…
In C vernacular the a single source file is generally called a "translation unit" after it's been preprocessed, etc. The translation units are then compiled independently to produce an object file of COFF format. I'm sure you already knew that,
Never heard "COFF" before, google says it's window's equivelant of ELF. Ok.
but the reason they produce the COFF files instead of just amalgamating all the translation units and then creating a binary is because the compiler and the linker have always been treated as entirely disparate entities. To compile does not mean to link, and to link does not mean to compile. You can compile without linking at all, and you can take those COFF files and link with a linker independent of your compiler (provided it understands COFF files). Most compilers these days combine the compiling and linking process, but they are two steps indeed.
<snip example>
In short: the reason it produces COFF files instead of just going straight to the binary is because compiling and linking are disparate processes; some compilers just combine the process.
Well, the situations I have in mind are ones where the objects are explicitly compiled seperately during the build, and then linked at the end – not anything to do with the automatic linking of headers and whatnot that gcc does for the individual object files. I.e. individual calls to gcc for each .c or .cc or whatever, and then a manual call to ld at the end to wrap it all together.
Duplicate File Cleaner
Re:IRC is more a conduit of tripe than knowledge. Most of the people that hang out supplement their lack of knowledge via insults, banning you because they're an op, etc. I don't believe I've been able to elicit a conversation worthy of note on IRC in years.
Anyway, moving on…
In C vernacular the a single source file is generally called a "translation unit" after it's been preprocessed, etc. The translation units are then compiled independently to produce an object file of COFF format. I'm sure you already knew that, but the reason they produce the COFF files instead of just amalgamating all the translation units and then creating a binary is because the compiler and the linker have always been treated as entirely disparate entities. To compile does not mean to link, and to link does not mean to compile. You can compile without linking at all, and you can take those COFF files and link with a linker independent of your compiler (provided it understands COFF files). Most compilers these days combine the compiling and linking process, but they are two steps indeed.
An example of why you might want to separate the process: some linkers have been known to emit metadata into the resultant binary (PE file in particular on Windows) that facilitates the runtime discernment of information otherwise not available. Java and .NET make use of this same concept in the form of a manifest. Windows makes use of certain fields in a PE file header that non-VC++ linkers simply don't emit. In the past I've actually used the MASM linker to link VC++ produced COFF files in order to reduce the resultant binary size (sometimes by as much as 50%+).
In short: the reason it produces COFF files instead of just going straight to the binary is because compiling and linking are disparate processes; some compilers just combine the process.
File R/d | Recover Deleted Files Or Permanently Delete Them
Re:Another problem people have is with multiple include files, is dependency issues.
And yes on reason for building source files into objects and then linking the objects is compile time.
If you ever work on a project with compile times in hours, you will easily know why.
However include files cause problems for some. If you change a header file, which a source file
is dependent on, if you have not set up your dependency correctly, when you rebuild those changes
will not be represented. Thats another reason I set up objects, because you can also set up dependency lists
for each object, so that every object file rebuilds when one of its dependencies change. Be it changes in the actual
source file or one of the headers the source file uses.
Home Office Electronic Filing System – No more messy files!
Re:Originally posted by: guy
When you #include, the preprocessor is just cuting and pasting the #included code where the include statement is.
Your question was why not have everything in 1 big source file rather than having your code spread across multiple files?
The two main reasons are compilation time (which was mentioned) and code organization and readibility.
It just makes sense to have all of the definition of one object in one file doesn't it? Things would get very messy very quickly if everything was mixed together. For small projects this isn't a problem, but when you are dealing with hundreds of thousands of lines of code, and many many user defined objects it is.
I realize that's how #include works, and I wasn't suggesting to only have one source file, only #include others. I don't see how that would be a problem with readability, and organization seems like it would be similar – with compiling a bunch of objects, you have to maintain your makefiles and whatnot, to make sure the right stuff gets built the right way. If you #included everything, you'd have to maintain correct #include statements.
So it seems like it boils down to compile time.
FileLock #1 Security Software**Up to $70/Sale**Crazy Conversion Hook!
Re:When you #include, the preprocessor is just cuting and pasting the #included code where the include statement is.
Your question was why not have everything in 1 big source file rather than having your code spread across multiple files?
The two main reasons are compilation time (which was mentioned) and code organization and readibility.
It just makes sense to have all of the definition of one object in one file doesn't it? Things would get very messy very quickly if everything was mixed together. For small projects this isn't a problem, but when you are dealing with hundreds of thousands of lines of code, and many many user defined objects it is.
Source Code Sale
Re:Originally posted by: guy
Originally posted by: guy
I'm not talking about external libraries though, I just mean for a single project (where the source files are all dependent on each other and not meant to be used independently), each .c file getting compiled individually into a .o, and then all billion of those .o's being linked together at the end. Why can't you just compile a single .c file, and it includes the others?
edit: I thought of a reason – only having to recompile the affected objects when you edit some code.
Compiling… you're likely going to have to recompile a lot more if yo uchange one file if they all include each other. If you make objects, and then link, you probably will only have to recompile that one module, and then link them again.
That's exactly what I meant. So, there's no real big technical reason, just a matter of convenience?
Midi Ringtone Software and Midi Files
Re:Originally posted by: guy
I'm not talking about external libraries though, I just mean for a single project (where the source files are all dependent on each other and not meant to be used independently), each .c file getting compiled individually into a .o, and then all billion of those .o's being linked together at the end. Why can't you just compile a single .c file, and it includes the others?
edit: I thought of a reason – only having to recompile the affected objects when you edit some code.
Compiling… you're likely going to have to recompile a lot more if yo uchange one file if they all include each other. If you make objects, and then link, you probably will only have to recompile that one module, and then link them again.
The Peoples Chemist Secret Health Files
Re:I'm not talking about external libraries though, I just mean for a single project (where the source files are all dependent on each other and not meant to be used independently), each .c file getting compiled individually into a .o, and then all billion of those .o's being linked together at the end. Why can't you just compile a single .c file, and it includes the others?
edit: I thought of a reason – only having to recompile the affected objects when you edit some code. ![]()
Re:I'm not sure what "difference" you're looking for, but conceptually each source file is independent. For example, you could actually compile code and distribute the compiled code and not the source code. This is commonly done via a DLL in the Windows environment anyway, but not always – often the compiled libraries are provided for linkage into a single executable. There are advantages to this, such as ease of distribution in a production environment. If you are a third-party vendor providing an API for your product, you would likely not want to provide the source code (for proprietary and support reasons), so you could provide a compiled library to be linked into the customers' projects.
0 Comments.