-I and -iquote

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
RustyFunkNut
Posts: 17
Joined: Mon Sep 26, 2005 5:10 am
Location: London, UK

-I and -iquote

Post by RustyFunkNut »

I've been having problems porting over an old project of mine to compile on the PSP. I tracked down one source of errors to parts of the STL which include <debug/debug.h> pulling in a file with that path/name in my project's root directory.

As I reference all my local headers using #include "" rather than #include <>, I tried using -I- in my Makefile to get around this like so:

Code: Select all

INCDIR = ./Source -
(which expands to -I./Source -I-). Unfortunately in gcc 3.4.4 -I- is deprecated and -iquote<path> is recommended instead. The only way around this I could find was by making this change to /psp/sdk/lib/build.mak:

Code: Select all

33c33
< CFLAGS   &#58;= $&#40;addprefix -I,$&#40;INCDIR&#41;&#41; $&#40;CFLAGS&#41;
---
> CFLAGS   &#58;= $&#40;addprefix -iquote,$&#40;LOCALINCDIR&#41;&#41; $&#40;addprefix -I,$&#40;INCDIR&#41;&#41; $&#40;CFLAGS&#41;
So basically I replace INCDIR with LOCALINCDIR in my Makefile, and everything works perfectly.

Hopefully this will be useful for anyone else struggling with similar issues. Is there any chance this change might be incorporated into a later version of the pspsdk?

Paul
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

Why can't you just do:

Code: Select all

CFLAGS = -iquote foo
in your own Makefile? Your CFLAGS come after the ones specified in build.mak, which is identical to your first example.
RustyFunkNut
Posts: 17
Joined: Mon Sep 26, 2005 5:10 am
Location: London, UK

Post by RustyFunkNut »

Good point...I'd not thought of that. I guess I was looking for a permanent solution rather than a quick fix. I'm happy to do this, but I thought it was something that could catch other people out. That and I like the idea of 'system' and 'local' includes being treated differently (it irks me when people do #include <localfile.h>, because I'm a pedant :))

Another thing I noticed was that the CFLAGS options get included in the CXXFLAGS and ASFLAGS options twice (in many of the samples at least). E.g. when I speicified:

Code: Select all

INCDIR = ./Blah -
CFLAGS = -O -G0 -Wall -DBLAH
I see this compile error with Foo.cpp:

Code: Select all

psp-g++  -I./Blah -I- -I. -I/usr/local/pspdev/psp/sdk/include -O -G0 -Wall -DBLAH  -I./Blah -I- -I. -I/usr/local/pspdev/psp/sdk/include -O -G0 -Wall -DBLAH -fno-exceptions -fno-rtti   -c -o Source/Foo.o Source/Foo.cpp
cc1plus&#58; note&#58; obsolete option -I- used, please use -iquote instead
cc1plus&#58; error&#58; -I- specified twice
Because $(CFLAGS) is concatenated to CXXFLAGS in both the Makefile and build.mak. It's not really a problem, but it doesn't seem like what was intended.

It's a minor issue anyway, I'm just glad my code is compiling :)
Post Reply