Hello Josh, this code you have shown makes one wrong assumption. You assume that on a successful call of an API the GetLastError() would have result of 0. This isn't true. If you want to enforce that, you need to use before this call an explicit 'SetLastError (0);' before calling the create-directory function.
I tested it with my current 4.7.0 toolchain for 32-bit and 64-bit, and I can't reproduce that the result would be 0 for it on second call. The error-code returned on second call is 183 for me. Nevertheless this is another wrong assumption you have within your code. You assume that process exit code has width of 32-bit. That's not true. The exit-code has range of 0-255 by C-runtime. Therefore, if you want to have exit-codes out-side this range, then you need to call explicit TerminateProcess. Regards, Kai 2012/3/18 Davidson, Josh <[email protected]>: > I installed Ruben's latest win32 build of mingw-w32 this afternoon and > immediately ran it runtime issues with third party libraries (one of which is > boost) that I'm using in my application. After some analysis, the root of > the issue is that the Windows's system error code is cleared upon a function > return. This has not been the behavior for previous releases MinGW. Below > is a simple program that creates a directory. If you run it twice (or create > c:\temp\zomg prior to running) it should exit with a return code of 183. > Using Ruben's latest mingw-w32 with gcc 4.7, it exits with 0, since the error > code is cleared upon returning from the function create. If you move the > code in that function to "main" everything works as intended. > > Is this going to be the way gcc 4.7 works (I know the return semantics have > changed slightly)? Or is this a problem with the current state of mingw-w32 > and/or Ruben's build? As far as I know, Ruben's build is the only > functioning win32 host build for mingw-w32 w/ gcc 4.7 (the CRT bundled with > the automated builds is missing symbols). > > [code] > #include <Windows.h> > > #include <iostream> > using namespace std; > > void create(const char* name) { > SECURITY_DESCRIPTOR sd; > InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION); > SetSecurityDescriptorDacl(&sd, true, 0, false); > SECURITY_ATTRIBUTES sa; > sa.nLength = sizeof(SECURITY_ATTRIBUTES); > sa.lpSecurityDescriptor = &sd; > sa.bInheritHandle = false; > > int val = CreateDirectoryA(name, &sa); > } > > int main() { > const char* name = "C:\\Temp\\zomg"; > create(name); > return GetLastError(); > } > [/code] > > ------------------------------------------------------------------------------ > This SF email is sponsosred by: > Try Windows Azure free for 90 days Click Here > http://p.sf.net/sfu/sfd2d-msazure > _______________________________________________ > Mingw-w64-public mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/mingw-w64-public -- | (\_/) This is Bunny. Copy and paste | (='.'=) Bunny into your signature to help | (")_(") him gain world domination ------------------------------------------------------------------------------ This SF email is sponsosred by: Try Windows Azure free for 90 days Click Here http://p.sf.net/sfu/sfd2d-msazure _______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
