Bug 47741 - -I- option stated obsolete considered worrying
Summary: -I- option stated obsolete considered worrying
Status: RESOLVED DUPLICATE of bug 19541
Alias: None
Product: gcc
Classification: Unclassified
Component: preprocessor (show other bugs)
Version: 4.4.5
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-14 22:51 UTC by Richard Sharman
Modified: 2011-02-15 13:44 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Sharman 2011-02-14 22:51:40 UTC
In gcc4.5 using the -I- option gives a warning saying it is obsolete
and to use -iquote.  
The -iquote option does not do what we require and
I am worried the option may be removed in the future.

Here is our situation where the functionality provided by -I- option
that is not provided by the -iquote option is required:


We have a large system and have many large include directories.  These
are all "user"  directories in the sense that they are independent of
the OS vendor include directories, So all these include are "FILE" not <FILE>.

A user testing changes adds a new directory to the front of the search
path to ensure that this new version is included.

Because with the -I- option searching is done in the listed order 
the new version is found.

Without the -I- option the include file may or may not be changed
file.  The "old" version is picked up if a file in that other
directory happens to include this file.

What would be nice would be an option to just honour the order of the
search directories. Failing that, please don't remove the -I option.
Thanks.


Here is a trivial example.  "new" represents the code to be tested,
"old" represents one of the include directories.  

* With the -I- the correct version of b.h is picked up

* Without the -I- the wrong version is picked up.

* (with -iquote the wrong version is picked up and the -E option seems
  to be ignored)

% sh Demo.sh
+ ls old new
new:
b.h

old:
a.h  b.h  main.c
+ head old/main.c old/a.h old/b.h new/b.h
==> old/main.c <==
#include "a.h"

==> old/a.h <==
char a_msg = "this is the old a.h file";
#include "b.h"

==> old/b.h <==
char b_msg "this is the original b.h  with syntax error, we dont want this";

==> new/b.h <==
char b_msg = "this is the new b.h -- we want this one";
+ gcc -I- -E -I new -I old old/main.c
cc1: note: obsolete option -I- used, please use -iquote instead
# 1 "old/main.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "old/main.c"
# 1 "old/a.h" 1
char a_msg = "this is the old a.h file";
# 1 "new/b.h" 1
char b_msg = "this is the new b.h -- we want this one";
# 2 "old/a.h" 2
# 1 "old/main.c" 2
+ gcc -E -I new -I old old/main.c
# 1 "old/main.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "old/main.c"
# 1 "old/a.h" 1
char a_msg = "this is the old a.h file";
# 1 "old/b.h" 1
char b_msg "this is the original b.h  with syntax error, we dont want this";
# 2 "old/a.h" 2
# 1 "old/main.c" 2
+ gcc -iquote -E -I new -I old old/main.c
In file included from old/main.c:1:
old/a.h:1: warning: initialization makes integer from pointer without a cast
old/a.h:1: error: initializer element is not computable at load time
In file included from old/a.h:2,
                 from old/main.c:1:
old/b.h:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before string constant
%
Comment 1 Andrew Pinski 2011-02-14 22:54:02 UTC
Dup of much older bug.

*** This bug has been marked as a duplicate of bug 19541 ***
Comment 2 Andrew Pinski 2011-02-14 22:55:08 UTC
Oh and -iquote takes an argument.
Comment 3 Richard Sharman 2011-02-15 13:44:38 UTC
> Oh and -iquote takes an argument.
Oh thanks!  How silly of me!   Thanks for the feedback. I did try 
searching for -I- by the way but it seemed to match everything with an I 
in it!  I tried quoting "-I-" but that didn't help.

Thanks
Richard