working with C++ includes and examining header files used in LLVM
-
Recently, I have been working with C++ includes and while examining those used in LLVM, I came across several H header files that caught my attention. I noticed that they were not templated and contained both declarations and definitions with code. To my surprise, I found that these header files were included in multiple CPP source files. Although they only define classes, I am concerned that this may result in code bloat since each source file must generate the binary for each class implementation. In my own work, I prefer to place the implementation of any non-templated class in its own CPP source file and let the linker handle it. I consider this to be essential. However, since the writers of LLVM are undoubtedly more knowledgeable, experienced, clever, and intelligent than I am, I wonder if there is something that I do not understand. Thank you.
-
Recently, I have been working with C++ includes and while examining those used in LLVM, I came across several H header files that caught my attention. I noticed that they were not templated and contained both declarations and definitions with code. To my surprise, I found that these header files were included in multiple CPP source files. Although they only define classes, I am concerned that this may result in code bloat since each source file must generate the binary for each class implementation. In my own work, I prefer to place the implementation of any non-templated class in its own CPP source file and let the linker handle it. I consider this to be essential. However, since the writers of LLVM are undoubtedly more knowledgeable, experienced, clever, and intelligent than I am, I wonder if there is something that I do not understand. Thank you.
Quote:
I came across several H header files that caught my attention. I noticed that they were not templated and contained both declarations and definitions with code.
Do you mean member functions implemented inside the class definitions (they are inlined, so multiple inclusion is allowed)?
"In testa che avete, Signor di Ceprano?" -- Rigoletto
-
Recently, I have been working with C++ includes and while examining those used in LLVM, I came across several H header files that caught my attention. I noticed that they were not templated and contained both declarations and definitions with code. To my surprise, I found that these header files were included in multiple CPP source files. Although they only define classes, I am concerned that this may result in code bloat since each source file must generate the binary for each class implementation. In my own work, I prefer to place the implementation of any non-templated class in its own CPP source file and let the linker handle it. I consider this to be essential. However, since the writers of LLVM are undoubtedly more knowledgeable, experienced, clever, and intelligent than I am, I wonder if there is something that I do not understand. Thank you.
-
There is plenty of information on the thinking behind this project at The LLVM Compiler Infrastructure Project[^].
Richard MacCutchan wrote:
There is plenty of information...
Am I misreading that? Seems like the project is focused on compilation? Thus why would the OP ask the question in the first place? An enterprise system will be vastly bigger than the compiler. That is going to be true for all but the very smallest of product companies. Service companies would probably always be bigger than that. Even a system which is doing dynamic compilation as part of the business logic should still restrict that part to a very small subset of of the system, and probably a company library. So am I just not understanding what LLVM is?
-
Richard MacCutchan wrote:
There is plenty of information...
Am I misreading that? Seems like the project is focused on compilation? Thus why would the OP ask the question in the first place? An enterprise system will be vastly bigger than the compiler. That is going to be true for all but the very smallest of product companies. Service companies would probably always be bigger than that. Even a system which is doing dynamic compilation as part of the business logic should still restrict that part to a very small subset of of the system, and probably a company library. So am I just not understanding what LLVM is?