User forums > Help
Possible to not precompile headers?
davereid20:
I'm working on a project for college and I've just started out using Code::Blocks Studio and I've been impressed so far as to make it my standard C++ IDE. Recently, I've been creating a templated Stack/Queue ADT and it seems to be fine except that Code::Blocks precompiles my header files (*.h.gch) of the templated struct/class and the MinGW throws an error that ".objs\StackNode.h.gch: file not recognized: File format not recognized"
I've included the project in a zip file. I'm using MinGW 3.4.5 (Candidate). When compiled with the Microsoft Visual C++ 2003 Toolkit, it compiles and runs without problems.
[attachment deleted by admin]
Ceniza:
In the project tree, right click on StackNode.h, select Properties and uncheck both "Compile file" and "Link file".
That done it compiles and links without problems (you don't need to compile that header file).
It's a shame only a few C++ compilers support exported templates, and g++ isn't one of those. Including a cpp file looks ugly :(
davereid20:
Ceniza,
Thanks for the help. I've got it to work. I guess I learned to use templates by declaring functions in the header file, put an #include "[classname].cpp" at the bottom of the header, and not put an #include "[classname].h" at the top of the .cpp file. Guess I can just continue doing it the same as non-templated classes. If anything else comes up, I'll post here.
davereid20:
Would there ever be an option to not precombile headers or will that not be ever useful?
Ceniza:
Well, if you want to do something more with a header than just including it, it's precompile it. If you are considering to compile it, think again if it should really be a header or a source file.
At least here adding a header file to a project won't check it for precompilation.
Navigation
[0] Message Index
[#] Next page
Go to full version