#716 problem with trailing slash in include path

closed-fixed
gcc (462)
2006-01-10
2005-02-02
weitzel
No

Hi,

there is probably a problem with gcc 3.4.2 (included in
MinGW 3.2.0-rc3) and trailing slash in an include path
when using "#include <header.h>" to include a header file.

for example:

create an empty bla.h and the following bla.c in your
current directory:
=== bla.c ===
#include <bla.h>
int main() { return 0; }
===========

compiling with "-I./" gives an error (bla.h: no such
file or dir.):
gcc -I./ bla.c
while compiling as follows works fine:
gcc -I. bla.c

Using #include "bla.h" instead od #include <bla.h> also
works.

Discussion

  • weitzel

    weitzel - 2005-02-02
    • status: open --> open-duplicate
     
  • weitzel

    weitzel - 2005-02-02

    Logged In: YES
    user_id=1208857

    This bug has probably the same cause as 1053052. However it
    is not limited to MSys' rxvt/bash combination

     
  • Danny Smith

    Danny Smith - 2005-02-02

    Logged In: YES
    user_id=11494

    What is your shell environment.

    Danny

     
  • weitzel

    weitzel - 2005-02-03

    Logged In: YES
    user_id=1208857

    I'm using Win 2K under Linux (Debian unstable, 2.6.10) +
    VMWare for porting my application to Win32. VMWare should
    not harm, I think (?!). See the attached text-file for shell
    env. under cmd.exe and MSys.

     
  • weitzel

    weitzel - 2005-02-03

    Environment variables under MSys

     
  • Danny Smith

    Danny Smith - 2005-02-03

    Logged In: YES
    user_id=11494

    Thanks,
    Now what does gcc -v -I./ bla.c show as being passed to
    cc1.exe. It should look something like:

    d:/mingw/bin/../libexec/gcc/mingw32/4.0.0/cc1.exe -quiet -
    v -I ./ -iprefix d:\mingw\bin\../lib/gcc/mingw32/4.0.0/ tst.c -
    quiet -dumpbase tst.c -auxbase tst -version -o
    D:\TEMP/ccobaaaa.s

    Danny

     
  • weitzel

    weitzel - 2005-02-07

    Logged In: YES
    user_id=1208857

    Hi, sorry for the delay ...

    here is the output of gcc -v -I./ bla.c

    Reading specs from W:/MinGW/bin/../lib/gcc/mingw32/3.4.2/specs
    Configured with: ../gcc/configure --with-gcc --with-gnu-ld
    --with-gnu-as --host=mingw32 --target=mingw32
    --prefix=/mingw --enable-threads --disable-nls
    --enable-languages=c,c++,f77,ada,objc,java
    --disable-win32-registry --disable-shared
    --enable-sjlj-exceptions --enable-libgcj --disable-java-awt
    --without-x --enable-java-gc=boehm --disable-libgcj-debug
    --enable-interpreter --enable-hash-synchronization
    --enable-libstdcxx-debug
    Thread model: win32
    gcc version 3.4.2 (mingw-special)
    W:/MinGW/bin/../libexec/gcc/mingw32/3.4.2/cc1.exe -quiet -v
    -I./ -iprefix W:\MinGW\bin\../lib/gcc/mingw32/3.4.2/ bla.c
    -quiet -dumpbase bla.c -auxbase bla -version -o
    C:/DOKUME~1/WEITZE~1.WEI/LOKALE~1/Temp/ccSeaaaa.s
    ignoring nonexistent directory
    "W:/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../mingw32/include"
    ignoring nonexistent directory
    "/mingw/lib/gcc/mingw32/3.4.2/../../../../mingw32/include"
    ignoring nonexistent directory "./"
    #include "..." search starts here:
    #include <...> search starts here:
    W:/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include
    W:/MinGW/bin/../lib/gcc/mingw32/3.4.2/include
    /mingw/lib/gcc/mingw32/3.4.2/../../../../include
    /mingw/include
    /mingw/lib/gcc/mingw32/3.4.2/include
    /mingw/include
    End of search list.
    GNU C version 3.4.2 (mingw-special) (mingw32)
    compiled by GNU C version 3.4.2 (mingw-special).
    GGC heuristics: --param ggc-min-expand=43 --param
    ggc-min-heapsize=24510
    bla.c:1:17: bla.h: No such file or directory
    ====

     
  • Danny Smith

    Danny Smith - 2005-02-08

    test app for stat behavior

     
  • Danny Smith

    Danny Smith - 2005-02-08

    Logged In: YES
    user_id=11494

    Thanks for the info. The error message probably comes from
    stat or fstat and I think I know where in gcc that the call to
    stat would cause this.

    But first I need to confirm that the behaviour of stat is the
    same on your system as on mine. Could you please build
    atached test case (changing the dir name C:/tmp to refer to
    an existing directory) and report results. This is what I get
    with my msvcrt.dll runtime on NT4:

    C: ERROR: No such file or directory
    C:/ is a directory
    C:\ is a directory
    C:/tmp is a directory
    C:\tmp is a directory
    C:\tmp\ ERROR: No such file or directory
    C:/tmp/ is a directory
    C:/tmp// is a directory
    C:/tmp\ ERROR: No such file or directory
    C:\tmp/ is a directory
    C:/tmp\/ is a directory
    C:/tmp/\ ERROR: No such file or directory
    C:/tmp/\/ is a directory
    .. is a directory
    ..\ is a directory
    ../ is a directory
    ../ is a directory
    ./..\ is a directory
    .\../ is a directory
    ./..\/ is a directory
    ./../\ is a directory
    ./../\/ is a directory

    It seems that forward slashes work always, trailing or not.
    Trailing backslashes cause problems in absolute paths, but
    not in relative paths. The root dir always needs a slash
    (foward or back).

    Strange rules. I wonder if they've bee changed.

    Danny

     
  • weitzel

    weitzel - 2005-02-08

    Logged In: YES
    user_id=1208857

    Hi,

    interestingly, my stat ("Microsoft Windows 2000 [Version
    5.00.2195]") behaves different:

    C: ERROR: No such file or directory
    C:/ is a directory
    C:\ is a directory
    C:/tmp is a directory
    C:\tmp is a directory
    C:\tmp\ ERROR: No such file or directory
    C:/tmp/ ERROR: No such file or directory
    C:/tmp// ERROR: No such file or directory
    C:/tmp\ ERROR: No such file or directory
    C:\tmp/ ERROR: No such file or directory
    C:/tmp\/ ERROR: No such file or directory
    C:/tmp/\ ERROR: No such file or directory
    C:/tmp/\/ ERROR: No such file or directory
    .. is a directory
    ..\ is a directory
    ../ is a directory
    ../ is a directory
    ./..\ is a directory
    .\../ is a directory
    ./..\/ is a directory
    ./../\ is a directory
    ./../\/ is a directory

    It seems that stat is really broken. Is MinGW's stat a
    wrapper to a stat in msvcrt.dll (which doesn't support "/"
    as path separator)?

     
  • weitzel

    weitzel - 2005-02-08

    Logged In: YES
    user_id=1208857

    Hi,

    there is no difference between the output under XP
    (Microsoft Windows XP [Version 5.1.2600]) and the output
    under W2k.

     
  • Onno Hommes

    Onno Hommes - 2005-06-20

    Logged In: YES
    user_id=122287

    All,

    I want to confirm this same problem. I currently have the
    same problem when I try to compile with the release of
    MinGW-4.1.0.exe

    This problem did not exist in gcc.exe (GCC) 3.2.3 (mingw
    special 20030504-1). MinGW-3.1.0-1.exe also doesn't have
    this problem.

    Hope this gets fixed soon! (I am runningWin2K SP4)

     
  • David Leonard

    David Leonard - 2005-07-01

    Logged In: YES
    user_id=10218

    Under WinXP 2002 SP2 with
    msvcrt.dll: 7.0.2600.2180 (xpsp_sp2_rtm.040803-2158)

    R:\Dev\Tmp>.\tst_stat
    C: ERROR: No such file or directory
    C:/ is a directory
    C:\ is a directory
    C:/tmp is a directory
    C:\tmp is a directory
    C:\tmp\ ERROR: No such file or directory
    C:/tmp/ ERROR: No such file or directory
    C:/tmp// ERROR: No such file or directory
    C:/tmp\ ERROR: No such file or directory
    C:\tmp/ ERROR: No such file or directory
    C:/tmp\/ ERROR: No such file or directory
    C:/tmp/\ ERROR: No such file or directory
    C:/tmp/\/ ERROR: No such file or directory
    .. is a directory
    ..\ ERROR: No such file or directory
    ../ ERROR: No such file or directory
    ../ ERROR: No such file or directory
    ./..\ ERROR: No such file or directory
    .\../ ERROR: No such file or directory
    ./..\/ ERROR: No such file or directory
    ./../\ ERROR: No such file or directory
    ./../\/ ERROR: No such file or directory

    Note that you get a different output when %CD% is C:\

    C:\&gt;r:tst_stat
    C: ERROR: No such file or directory
    C:/ is a directory
    C:\ is a directory
    C:/tmp is a directory
    C:\tmp is a directory
    C:\tmp\ ERROR: No such file or directory
    C:/tmp/ ERROR: No such file or directory
    C:/tmp// ERROR: No such file or directory
    C:/tmp\ ERROR: No such file or directory
    C:\tmp/ ERROR: No such file or directory
    C:/tmp\/ ERROR: No such file or directory
    C:/tmp/\ ERROR: No such file or directory
    C:/tmp/\/ ERROR: No such file or directory
    .. is a directory
    ..\ is a directory
    ../ is a directory
    ../ is a directory
    ./..\ is a directory
    .\../ is a directory
    ./..\/ is a directory
    ./../\ is a directory
    ./../\/ is a directory

     
  • David Leonard

    David Leonard - 2005-07-01

    Logged In: YES
    user_id=10218

    It turns out that _stat is a wrapper around FindFirstFile(),
    which is documented thusly:

    "To examine a directory that is not a root directory, use
    the path to that directory, without a trailing backslash.
    For example, an argument of "C:\windows" returns information
    about the directory "C:\windows", not about a directory or
    file in "C:\windows". An attempt to open a search with a
    trailing backslash always fails."

    http://msdn.microsoft.com/library/en-us/fileio/fs/findfirstfile.asp

     
  • Danny Smith

    Danny Smith - 2006-01-10

    Logged In: YES
    user_id=11494

    Fixed in mingw gcc-3.4.5 RC
    Danny

     
  • Danny Smith

    Danny Smith - 2006-01-10
    • status: open-duplicate --> closed-fixed
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks