Windows SEH

CodeLite installation/troubleshooting forum
BOURGER
CodeLite Curious
Posts: 7
Joined: Fri Jun 06, 2014 10:14 pm
Genuine User: Yes
IDE Question: C++
Contact:

Windows SEH

Post by BOURGER » Sun Jun 08, 2014 5:58 pm

Hello,

I work with Windows XP SP3.
I downloaded the CodeLite 6.0 and MinGW 4.8.1 package from SourceForge.
I am learning Win32.
I have tried some programs and all was OK until I tried the Windows SEH.
I get errors such as:
'EM_OVERFLOW' undeclared
'EM_UNDERFLOW' undeclared
'__try' undeclared
etc

Questions:

- Does the MinGW 4.8.1 release from SourceForge support SEH ?
On a post from 2010 I read: "It appears that the GCC compilers (and hence, MinGW) do not support SEH."
One month later, on another post: "Structured error handling is fully supported by the Gnu C++ compiler. "

- To make a long story short, is this SEH support only on C++ and excluded on the C compler ? Or is it something to activate on the CodeLite IDE to get this support ?

- If the MinGW 4.8.1 release from SourceForge does not support SEH, is it possible to get a link to download a C compiler which could support the Windows SEH ?

Thanks

User avatar
eranif
CodeLite Plugin
Posts: 5934
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Windows SEH

Post by eranif » Sun Jun 08, 2014 6:46 pm

BOURGER wrote:Or is it something to activate on the CodeLite IDE to get this support ?
No, codelite is not a compiler.
The MinGW that comes with codelite is using sjlj
Other than that, you can check the compiler website here: http://tdm-gcc.tdragon.net/quirks

The one that comes with codelite does not support SEH, however, they offer another version of the compiler - download and install it.
And then let codelite detect it from:
Settings -> Build Settings -> Auto detect compilers

Eran
Make sure you have read the HOW TO POST thread

BOURGER
CodeLite Curious
Posts: 7
Joined: Fri Jun 06, 2014 10:14 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Windows SEH

Post by BOURGER » Sun Jun 08, 2014 9:47 pm

I downloaded TDM-GCC-64.
I installed it.
I pushed the button auto-detect compiler.
The TDM-GCC-64 is recognized and I clicked twice on it to make it the default compiler.
I removed the dot from the library path and added the -m64 option to the compiler.
But when I compile and then I check the log, I can see that the -m64 option is there but that the Windows SEH is not recognized.

Nevertheless, I read at the URL http://tdm-gcc.tdragon.net/quirks:

TDM64 exception unwinder formats (SJLJ and 64-bit SEH)

The TDM64 edition of TDM-GCC also has two different flavors of exception propagation.
Which flavor is used depends on whether you create a 64-bit or a 32-bit binary.
64-bit binaries use "SEH", which stands for "Structured Exception Handling".
This is the same type of exception handling that 64-bit programs generated by Microsoft Visual C/C++ use.

As I added the -m64 flag (which is the default) I wonder what is missing.
Anyone for an answer ?

Thanks

User avatar
eranif
CodeLite Plugin
Posts: 5934
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Windows SEH

Post by eranif » Sun Jun 08, 2014 11:05 pm

Please post the build log.
Also, make sure that the new compiler is indeed used in your project settings:
Open the project settings -> General -> Common Settings
and make sure that the selected compiler is the correct one

Eran
Make sure you have read the HOW TO POST thread

BOURGER
CodeLite Curious
Posts: 7
Joined: Fri Jun 06, 2014 10:14 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Windows SEH

Post by BOURGER » Mon Jun 09, 2014 5:30 pm

I opened the project settings -> General -> Common Settings
I selected the TDM-GCC-64 compiler by clicking twice: the selected compiler was then written in bold.
I exited from the mini-window and from the settings.
But then I entered again to check if the compiler was really selected: the old compiler was still there in bold.
Impossible to get the TDM-GCC-64 compiler as the default compiler.
After 3 tries I exited from CodeLite and removed the old unnecessary compilers
Finally I succeeded to get the TDM-GCC-64 compiler as the default compiler, but I think something is wrong in the compiler selection.
I can add that I did that before so send my post.

Thereafter the Buildlog.txt:

C:\WINDOWS\system32\cmd.exe /c "f:/TDM-GCC-64/bin/mingw32-make.exe -j2 -e -f Makefile"
----------Building project:[ Exception - Debug ]----------
mingw32-make[1]: Entering directory 'F:/Tries_CL/Exception'
f:\TDM-GCC-64\bin\gcc.exe -c "F:/Tries_CL/Exception/main.c" -g -O0 -Wall -m64 -o ./Debug/main.c.o -I.
F:/Tries_CL/Exception/main.c: In function 'main':
F:/Tries_CL/Exception/main.c:19:20: error: 'EM_OVERFLOW' undeclared (first use in this function)
FPNew = FPOld & ~(EM_OVERFLOW | EM_UNDERFLOW | EM_INEXACT
^
F:/Tries_CL/Exception/main.c:19:20: note: each undeclared identifier is reported only once for each function it appears in
F:/Tries_CL/Exception/main.c:19:34: error: 'EM_UNDERFLOW' undeclared (first use in this function)
FPNew = FPOld & ~(EM_OVERFLOW | EM_UNDERFLOW | EM_INEXACT
^
F:/Tries_CL/Exception/main.c:19:49: error: 'EM_INEXACT' undeclared (first use in this function)
FPNew = FPOld & ~(EM_OVERFLOW | EM_UNDERFLOW | EM_INEXACT
^
F:/Tries_CL/Exception/main.c:20:6: error: 'EM_ZERODIVIDE' undeclared (first use in this function)
| EM_ZERODIVIDE | EM_DENORMAL | EM_INVALID);
^
F:/Tries_CL/Exception/main.c:20:22: error: 'EM_DENORMAL' undeclared (first use in this function)
| EM_ZERODIVIDE | EM_DENORMAL | EM_INVALID);
^
F:/Tries_CL/Exception/main.c:20:36: error: 'EM_INVALID' undeclared (first use in this function)
| EM_ZERODIVIDE | EM_DENORMAL | EM_INVALID);
^
F:/Tries_CL/Exception/main.c:22:21: error: 'MCW_EM' undeclared (first use in this function)
_controlfp (FPNew, MCW_EM);
^
F:/Tries_CL/Exception/main.c:23:16: error: '__try' undeclared (first use in this function)
while (!Done) __try {
^
F:/Tries_CL/Exception/main.c:23:22: error: expected ';' before '{' token
while (!Done) __try {
^
F:/Tries_CL/Exception/main.c:12:10: warning: unused variable 'pNull' [-Wunused-variable]
LPDWORD pNull = NULL;
^
F:/Tries_CL/Exception/main.c:11:28: warning: unused variable 'iy' [-Wunused-variable]
DWORD ECatgry, i = 0, ix, iy = 0;
^
F:/Tries_CL/Exception/main.c:11:24: warning: unused variable 'ix' [-Wunused-variable]
DWORD ECatgry, i = 0, ix, iy = 0;
^
F:/Tries_CL/Exception/main.c:11:17: warning: unused variable 'i' [-Wunused-variable]
DWORD ECatgry, i = 0, ix, iy = 0;
^
F:/Tries_CL/Exception/main.c:11:8: warning: unused variable 'ECatgry' [-Wunused-variable]
DWORD ECatgry, i = 0, ix, iy = 0;
^
F:/Tries_CL/Exception/main.c: At top level:
F:/Tries_CL/Exception/main.c:87:14: error: static declaration of 'Filter' follows non-static declaration
static DWORD Filter (LPEXCEPTION_POINTERS pExP, LPDWORD ECatgry)
^
F:/Tries_CL/Exception/main.c:7:7: note: previous declaration of 'Filter' was here
DWORD Filter (LPEXCEPTION_POINTERS, LPDWORD);
^
F:/Tries_CL/Exception/main.c: In function 'Filter':
F:/Tries_CL/Exception/main.c:96:2: warning: format '%x' expects argument of type 'unsigned int', but argument 2 has type 'DWORD' [-Wformat=]
_tprintf (_T ("Filter. ExCode: %x\n"), ExCode);
^
F:/Tries_CL/Exception/main.c:113:5: warning: format '%d' expects argument of type 'int', but argument 2 has type 'DWORD' [-Wformat=]
ReadWrite, VirtAddr);
^
F:/Tries_CL/Exception/main.c:113:5: warning: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'DWORD' [-Wformat=]
F:/Tries_CL/Exception/main.c: At top level:
F:/Tries_CL/Exception/main.c:87:14: warning: 'Filter' defined but not used [-Wunused-function]
static DWORD Filter (LPEXCEPTION_POINTERS pExP, LPDWORD ECatgry)
^
F:/Tries_CL/Exception/main.c: In function 'main':
F:/Tries_CL/Exception/main.c:85:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
mingw32-make[1]: *** [Debug/main.c.o] Error 1
mingw32-make.exe: *** [All] Error 2
Exception.mk:95: recipe for target 'Debug/main.c.o' failed
mingw32-make[1]: Leaving directory 'F:/Tries_CL/Exception'
Makefile:4: recipe for target 'All' failed
11 errors, 12 warnings

I can add that my host is 32 bits, running Windows XP3 and CodeLite 6.0

User avatar
eranif
CodeLite Plugin
Posts: 5934
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Windows SEH

Post by eranif » Mon Jun 09, 2014 5:41 pm

Finally I succeeded to get the TDM-GCC-64 compiler as the default compiler, but I think something is wrong in the compiler selection.
First, let me explain what does "Default Compiler" means:
codelite detects N compilers on your machine and it imports all of them.
Some of the compilers may be missing some tool (e.g. VC does not have mingw32-make.exe which is required by codelite) is such cases the "Default" compiler toolchain are using to complete
any missing tools.
Some compilers (like clang for windows) need some extra paths in order to work properly, again, codelite will complete the missing paths from the "Default" compiler.

Now, to tell your project to use a given compiler, you need to change it in the project level ( as I wrote before ):

Open the project settings -> common settings -> general
and under "Compiler" make sure that TDM 64 _is_ selected. this is how you change compiler for a project
Thereafter the Buildlog.txt:
The errors you are having are not related to codelite and it seems like that TDM-64 does not support it (despite what the website says)

Eran
Make sure you have read the HOW TO POST thread

Post Reply