Simple C++ Compile Error

Tim Van Holder tim.vanholder at anubex.com
Tue Aug 12 09:01:45 CEST 2008


On 2008-08-12 02:43, Marc Glisse wrote:
> On Mon, 11 Aug 2008, Robert Evans wrote:
> 
>> Source:
>> #include </home/bevans/gmp-4.2.3/include/gmpxx.h>
> 
> This is not the right way to specify the location of the header file. You 
> should have: #include <gmpxx.h>
> and then on the command line, you add -I/home/.../include
> 
> gmpxx.h includes gmp.h. With what you have shown, the compiler should not 
> be able to find gmp.h in /home/.../include. The fact that it does not 
> complain means it has found a gmp.h file somewhere, likely some old 
> version in /usr/include.
> 
> If that does not help, you'll need to add -E to the command line and look 
> at the relevant parts of what it outputs.

While Robert's code is unusual (especially the use of <> instead of "" 
when specifying a full path to a header), it's certainly valid C++.

Would it not make sense for gmpxx.h to include gmp.h with '#include 
"gmp.h"'?
That way, no matter how you include gmpxx.h, it will prefer the gmp.h 
that sits alongside it.


More information about the gmp-bugs mailing list