in reply to Re^3: true from (-e "") on Windoze (" is an illegal filename character
in thread true from (-e "") on Windoze
I don't know what combination of compiler and OS you use, but on my system (Win7 Ult + Strawberry 5.14.2 x64), your unmodified code clearly shows that stat() fails:
X:\>gcc -Wall --pedantic -o 979536.exe 979536.c 979536.c: In function 'main': 979536.c:18: warning: ISO C does not support the 'I64' ms_printf lengt +h modifier 979536.c:18: warning: ISO C does not support the 'I64' ms_printf lengt +h modifier 979536.c:18: warning: ISO C does not support the 'I64' ms_printf lengt +h modifier 979536.c:18: warning: format '%d' expects type 'int', but argument 11 +has type '_off_t' 979536.c:29: warning: ISO C does not support the 'I64' ms_printf lengt +h modifier 979536.c:29: warning: ISO C does not support the 'I64' ms_printf lengt +h modifier 979536.c:29: warning: ISO C does not support the 'I64' ms_printf lengt +h modifier 979536.c:29: warning: format '%d' expects type 'int', but argument 11 +has type '_off_t' X:\>979536.exe for ""; stat returned: -1 gid: 0 atime:0 ctime:0 drive:0 inode:0 mode:0 mtime:0 nlink:0 rdev:0 size:0 uid:0 For (null); stat returned: -1 gid: 0 atime:0 ctime:0 drive:0 inode:0 mode:0 mtime:0 nlink:0 rdev:0 size:0 uid:0 X:\>gcc --version gcc (GCC) 4.4.7 20111023 (prerelease) [svn/rev.180339 - mingw-w64/oz] Copyright (C) 2010 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There i +s NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PUR +POSE. X:\>
Alexander
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: true from (-e "") on Windoze (" is an illegal filename character
by BrowserUk (Patriarch) on Jul 03, 2012 at 19:47 UTC | |
I don't know what combination of compiler and OS you use MS compiler; Vista 64-bit. but on my system (Win7 Ult + Strawberry 5.14.2 x64), What do you expect the gcc CRT to emulate? With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] |
by afoken (Chancellor) on Jul 05, 2012 at 20:13 UTC | |
What do you expect the gcc CRT to emulate? Nothing. stat (via _stat64) is available from msvcrt.dll, as documented by Microsoft. For the return value, MS writes: Each of these functions returns 0 if the file-status information is obtained. A return value of –1 indicates an error, in which case errno is set to ENOENT, indicating that the filename or path could not be found. A return value of EINVAL indicates an invalid parameter; errno is also set to EINVAL in this case. So, let's have a look at errno:
Output:
I think this is what one should expect. The file "" does not exist, and NULL is an invalid parameter. For the current directory and the exe file, stat() returns 0, as expected, and errno is not touched at all, so it stays 2 from the previously failed stat(). Alexander
-- Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-) | [reply] [d/l] [select] |
by BrowserUk (Patriarch) on Jul 05, 2012 at 20:39 UTC | |
I think ... Sorry. But you are still wrong. Trying to draw conclusions about what the MS compiler does, from what you can observe from compiling similar code using the Mingw; is like trying to draw conclusions about the AC Cobra from driving a DAX 427 kit car. Observe:
That code, compiled with an MS compiler, doesn't import anything from msvcrt.dll! I'll let you work out why for yourself. With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] [d/l] |
|
Re^5: true from (-e "") on Windoze (" is an illegal filename character
by Anonymous Monk on Jul 03, 2012 at 19:44 UTC | |
Maybe gcc ( objdump -p ..dllorexe... |grep DLL.Name ---- libgcc_s_dw2-1.dll ) supplies its own stat? | [reply] [d/l] |
by afoken (Chancellor) on Jul 05, 2012 at 19:55 UTC | |
Process Explorer shows that BrowserUK's test program uses msvcrt.dll from C:\Windows\System32\msvcrt.dll. This DLL is part of Windows 7, with file and product version both set to 7.0.7601.17744. It seems that msvcrt.dll loads several other DLLs (apisetschema.dll 6.1.7600.16385, kernelbase.dll 6.1.7601.17651, ntdll.dll 6.1.7601.17725) all from C:\Windows\System32, all from Microsoft. The program itself also uses kernel32.dll 6.1.7601.17651, of course from C:\Windows\System32, delivered by Microsoft. No other DLLs are loaded, and not a single DLL comes from the MinGW installation that came with Straberry Perl. Alexander
-- Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-) | [reply] [d/l] |
|
Re^5: true from (-e "") on Windoze (" is an illegal filename character
by Anonymous Monk on Jul 03, 2012 at 19:48 UTC | |
| [reply] [d/l] |