On OS: XP 2002 professional SP2, for verifying the correct installations of the downloaded programs below, the steps carried out were as follows:
(download page: http://wingtk.sourceforge.net/index.html)
wGLADE-0.2:
-- Creating example "first.glade" based on "Getting started with winGTK and wGLADE" tutorial
(see: http://wingtk.sourceforge.net/tutorial.html)
-- Creating source & header files (main, callbacks, interface, support) and "makefile"
-- Modifying "callbacks.c" (adding "#include <windows.h>" and message line)
WinGTK:
-- Running "make.exe -f makefile" to generate "first.exe"
-- Executing "first.exe" --> example "first" verified, running succesfully!!!
Dev-C++ (4.9.9.2) & DevEx(0.1.1.exe):
-- Creating Project1 based on "GUI toolkit" GTK+ 1.3 (using DevEx)
-- Adding source & header files generated by WinGlade (and used for WinGTK)
-- Modifying "main.c": adding "#define HAVE_CONFIG_H 1"
-- Compiling and linking Project1:
Errors:0
Warnings:4 - "extra tokens at end of #endif directive"
-- Running "Project1.exe":
GTK-ERROR**: incompatible Build!
The code using GTK+ thinks GtkWindow is of different
size than it actually is in this build of GTK.
On Windows, this probably means that you have compiled
your code with gcc without the -fnative-struct switch.
aborting... --> Runtime error!
Comment: In DevC++ in the settings for Project1 the parameters for the compiler are:
-mwindows -mno-cygwin -fnative-struct -DHAVE_CONFIG_H
Compile Log: (some words in Hungarian: “indítása”=starting, “Feladat befejezve”=End of task, “Sikeres fordítás”=Successful compillation)
Fordító: Default compiler
Building Makefile: "D:-\Makefile.win"
make... indítása.
make.exe -f "D:-\Makefile.win" all
g++.exe -c support.c -o support.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" -I"C:/Dev-Cpp/INCLUDE/GDK" -I"C:/Dev-Cpp/include/gtk"
In file included from C:/Dev-Cpp/include/gdk/gdk.h:33,
from C:/Dev-Cpp/include/gtk/gtk.h:31,
from support.c:14:
C:/Dev-Cpp/include/gdk/gdkdnd.h:99:8: warning: extra tokens at end of #endif directive
g++.exe -c interface.c -o interface.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" -I"C:/Dev-Cpp/INCLUDE/GDK" -I"C:/Dev-Cpp/include/gtk"
In file included from C:/Dev-Cpp/include/gdk/gdk.h:33,
from C:/Dev-Cpp/include/gtk/gtk.h:31,
from interface.c:15:
C:/Dev-Cpp/include/gdk/gdkdnd.h:99:8: warning: extra tokens at end of #endif directive
g++.exe -c main.c -o main.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" -I"C:/Dev-Cpp/INCLUDE/GDK" -I"C:/Dev-Cpp/include/gtk"
In file included from C:/Dev-Cpp/include/gdk/gdk.h:33,
from C:/Dev-Cpp/include/gtk/gtk.h:31,
from main.c:10:
C:/Dev-Cpp/include/gdk/gdkdnd.h:99:8: warning: extra tokens at end of #endif directive
g++.exe -c callbacks.c -o callbacks.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" -I"C:/Dev-Cpp/INCLUDE/GDK" -I"C:/Dev-Cpp/include/gtk"
In file included from C:/Dev-Cpp/include/gdk/gdk.h:33,
from C:/Dev-Cpp/include/gtk/gtk.h:31,
from callbacks.c:5:
C:/Dev-Cpp/include/gdk/gdkdnd.h:99:8: warning: extra tokens at end of #endif directive
g++.exe support.o interface.o main.o callbacks.o -o "Projekt1.exe" -L"C:/Dev-Cpp/lib" -L"C:/Dev-Cpp/Lib/libz.a" -L"C:/Dev-Cpp/Lib/libglib-2.0.dll.a" -L"C:/Dev-Cpp/Lib/libgtk.dll.a" -L"C:/Dev-Cpp/Lib/libgdk.dll.a" -mwindows C:/Dev-Cpp/Lib/libz.a C:/Dev-Cpp/Lib/libglib-2.0.dll.a C:/Dev-Cpp/Lib/libgtk.dll.a C:/Dev-Cpp/Lib/libgdk.dll.a
Feladat befejezve
Sikeres fordítás
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The message is quite clear and rather helpfull (although of course it is in English, so that's easy for me to say!), it says that for Dev-C++, you need to set the following compiler options:
of these you only have -mwindows set (probably by specifying a GUI build). Add these options in the Project->Options->Compiler->C++ options box in Dev-C++.
Is bad advice and probably wrong, and conflicts with the suggested options settings. If you did that, it would only apply to the code within main.c, and then only from the point of definition. Specifying -DHAVE_CONFIG_H ensures that the macro is defined for all project files including headers. The information is conflicting because for -DHAVE_CONFIG_H it is defined, but with no particular value, but the #define explicitly sets it to 1. This is probably unnecessary, and is merely the result of misunderstanding of the preprocessor by whoever wrote that. I cannot actually find where that text came from amongst the links you posted.
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
> C:/Dev-Cpp/include/gdk/gdkdnd.h:99:8: warning: extra tokens at end of #endif directive
I would fix that if I were you. It is helpful to remove all warnings so that you are less likely to ignore them when they occur in your own code. It also means you can use the -Werrror option to make all warnings errors so that you have to fix them.
My guess is that at line 99 on gdkdnd.h, it has something like:
Thanks for your really detailed answer! Based on it understanding more I recognized some mistakes I made, and have some new problems also.
1.
The switches used for Project1 (-mwindows -mno-cygwin -fnative-struct -DHAVE_CONFIG_H) come from the template GUI Toolkits – GTK+ 1.3 (Using DevEx) when generating a new C++ project, and can be checked thru the menu “Project options/parameters/Compiler” (but not in C++ compiler!). But analyzing the generated makefile, the added C source files were compiled as C++ files, so the switches had not been applied for them.
2.
Now I started from the beginning, with creating a new project using the same GUI GTK template, but instead of the default C++ Project, I selected “C Project”. After it all the switches work, except the switch -fnative-struct. If it is listed among the other switch, I get the cc1.exe compiler error message: unrecognized command line option "-fnative-struct".
3.
Regarding gdkdnd.h, you are right, in the installed Dev-C++ (4.9.9.2) & DevEx(0.1.1.exe) this header file ends with “#endif GDK_DND_H” instead of with “#endif /GDK_DND_H/”. Correcting it there is no relating warning message any more.
4.
Summarizing the results:
Compiling with the -fnative-struct switch this switch is unrecognized.
Compiling without the -fnative-struct switch and running the generated exe file there is still a runtime error:
>The code using GTK+ thinks GtkWindow is of different
>size than it actually is in this build of GTK.
>On Windows, this probably means that you have compiled
>your code with gcc without the -fnative-struct switch.
>aborting... --> Runtime error!
5.
This is the content of the makefile generated Dev-C++:
On OS: XP 2002 professional SP2, for verifying the correct installations of the downloaded programs below, the steps carried out were as follows:
(download page: http://wingtk.sourceforge.net/index.html)
-- Creating example "first.glade" based on "Getting started with winGTK and wGLADE" tutorial
(see: http://wingtk.sourceforge.net/tutorial.html)
-- Creating source & header files (main, callbacks, interface, support) and "makefile"
-- Modifying "callbacks.c" (adding "#include <windows.h>" and message line)
-- Running "make.exe -f makefile" to generate "first.exe"
-- Executing "first.exe" --> example "first" verified, running succesfully!!!
-- Creating Project1 based on "GUI toolkit" GTK+ 1.3 (using DevEx)
-- Adding source & header files generated by WinGlade (and used for WinGTK)
-- Modifying "main.c": adding "#define HAVE_CONFIG_H 1"
-- Compiling and linking Project1:
Errors:0
Warnings:4 - "extra tokens at end of #endif directive"
-- Running "Project1.exe":
GTK-ERROR**: incompatible Build!
The code using GTK+ thinks GtkWindow is of different
size than it actually is in this build of GTK.
On Windows, this probably means that you have compiled
your code with gcc without the -fnative-struct switch.
aborting... --> Runtime error!
Comment: In DevC++ in the settings for Project1 the parameters for the compiler are:
-mwindows -mno-cygwin -fnative-struct -DHAVE_CONFIG_H
Compile Log: (some words in Hungarian: “indítása”=starting, “Feladat befejezve”=End of task, “Sikeres fordítás”=Successful compillation)
Fordító: Default compiler
Building Makefile: "D:-\Makefile.win"
make... indítása.
make.exe -f "D:-\Makefile.win" all
g++.exe -c support.c -o support.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" -I"C:/Dev-Cpp/INCLUDE/GDK" -I"C:/Dev-Cpp/include/gtk"
In file included from C:/Dev-Cpp/include/gdk/gdk.h:33,
from C:/Dev-Cpp/include/gtk/gtk.h:31,
from support.c:14:
C:/Dev-Cpp/include/gdk/gdkdnd.h:99:8: warning: extra tokens at end of #endif directive
g++.exe -c interface.c -o interface.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" -I"C:/Dev-Cpp/INCLUDE/GDK" -I"C:/Dev-Cpp/include/gtk"
In file included from C:/Dev-Cpp/include/gdk/gdk.h:33,
from C:/Dev-Cpp/include/gtk/gtk.h:31,
from interface.c:15:
C:/Dev-Cpp/include/gdk/gdkdnd.h:99:8: warning: extra tokens at end of #endif directive
g++.exe -c main.c -o main.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" -I"C:/Dev-Cpp/INCLUDE/GDK" -I"C:/Dev-Cpp/include/gtk"
In file included from C:/Dev-Cpp/include/gdk/gdk.h:33,
from C:/Dev-Cpp/include/gtk/gtk.h:31,
from main.c:10:
C:/Dev-Cpp/include/gdk/gdkdnd.h:99:8: warning: extra tokens at end of #endif directive
g++.exe -c callbacks.c -o callbacks.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" -I"C:/Dev-Cpp/INCLUDE/GDK" -I"C:/Dev-Cpp/include/gtk"
In file included from C:/Dev-Cpp/include/gdk/gdk.h:33,
from C:/Dev-Cpp/include/gtk/gtk.h:31,
from callbacks.c:5:
C:/Dev-Cpp/include/gdk/gdkdnd.h:99:8: warning: extra tokens at end of #endif directive
g++.exe support.o interface.o main.o callbacks.o -o "Projekt1.exe" -L"C:/Dev-Cpp/lib" -L"C:/Dev-Cpp/Lib/libz.a" -L"C:/Dev-Cpp/Lib/libglib-2.0.dll.a" -L"C:/Dev-Cpp/Lib/libgtk.dll.a" -L"C:/Dev-Cpp/Lib/libgdk.dll.a" -mwindows C:/Dev-Cpp/Lib/libz.a C:/Dev-Cpp/Lib/libglib-2.0.dll.a C:/Dev-Cpp/Lib/libgtk.dll.a C:/Dev-Cpp/Lib/libgdk.dll.a
Feladat befejezve
Sikeres fordítás
Here is the sulution for the error:
With gcc-3.x, replace -fnative-struct with -mms-bitfields.
(http://bbs.linuxeden.com/archiver/tid-70558.html)
My Dev-C++ system has Gcc 3.4.2, and with this alternative switch the example first.exe is now running properly.
I suggest to publicate this, calling programmers (beginners!!!) attention for this necessary replacement.
B. Barni
The message is quite clear and rather helpfull (although of course it is in English, so that's easy for me to say!), it says that for Dev-C++, you need to set the following compiler options:
-mwindows -mno-cygwin -fnative-struct -DHAVE_CONFIG_H
of these you only have -mwindows set (probably by specifying a GUI build). Add these options in the Project->Options->Compiler->C++ options box in Dev-C++.
The following:
> -- Modifying "main.c": adding "#define HAVE_CONFIG_H 1"
Is bad advice and probably wrong, and conflicts with the suggested options settings. If you did that, it would only apply to the code within main.c, and then only from the point of definition. Specifying -DHAVE_CONFIG_H ensures that the macro is defined for all project files including headers. The information is conflicting because for -DHAVE_CONFIG_H it is defined, but with no particular value, but the #define explicitly sets it to 1. This is probably unnecessary, and is merely the result of misunderstanding of the preprocessor by whoever wrote that. I cannot actually find where that text came from amongst the links you posted.
Clifford
PS:
Regarding
> C:/Dev-Cpp/include/gdk/gdkdnd.h:99:8: warning: extra tokens at end of #endif directive
I would fix that if I were you. It is helpful to remove all warnings so that you are less likely to ignore them when they occur in your own code. It also means you can use the -Werrror option to make all warnings errors so that you have to fix them.
My guess is that at line 99 on gdkdnd.h, it has something like:
endif some comment
rather than
endif / some comment /
However looking at it here: https://stage.maemo.org/svn/maemo/projects/haf/trunk/gtk+/gdk/gdkdnd.h
it has
endif / GDK_DND_H /
which should be Ok. Make sure that this a blank line at the end of the file (i.e. at least one newline after the #endif.
Clifford
Thanks for your really detailed answer! Based on it understanding more I recognized some mistakes I made, and have some new problems also.
1.
The switches used for Project1 (-mwindows -mno-cygwin -fnative-struct -DHAVE_CONFIG_H) come from the template GUI Toolkits – GTK+ 1.3 (Using DevEx) when generating a new C++ project, and can be checked thru the menu “Project options/parameters/Compiler” (but not in C++ compiler!). But analyzing the generated makefile, the added C source files were compiled as C++ files, so the switches had not been applied for them.
2.
Now I started from the beginning, with creating a new project using the same GUI GTK template, but instead of the default C++ Project, I selected “C Project”. After it all the switches work, except the switch -fnative-struct. If it is listed among the other switch, I get the cc1.exe compiler error message: unrecognized command line option "-fnative-struct".
3.
Regarding gdkdnd.h, you are right, in the installed Dev-C++ (4.9.9.2) & DevEx(0.1.1.exe) this header file ends with “#endif GDK_DND_H” instead of with “#endif / GDK_DND_H /”. Correcting it there is no relating warning message any more.
4.
Summarizing the results:
Compiling with the -fnative-struct switch this switch is unrecognized.
Compiling without the -fnative-struct switch and running the generated exe file there is still a runtime error:
>The code using GTK+ thinks GtkWindow is of different
>size than it actually is in this build of GTK.
>On Windows, this probably means that you have compiled
>your code with gcc without the -fnative-struct switch.
>aborting... --> Runtime error!
5.
This is the content of the makefile generated Dev-C++:
Project: Project1
Makefile created by Dev-C++ 4.9.9.2
CPP = g++.exe
CC = gcc.exe
WINDRES = windres.exe
RES =
OBJ = support.o callbacks.o interface.o main.o $(RES)
LINKOBJ = support.o callbacks.o interface.o main.o $(RES)
LIBS = -L"C:/Dev-Cpp/lib" -L"C:/Dev-Cpp/Lib/libz.a" -L"C:/Dev-Cpp/Lib/libglib-2.0.dll.a" -L"C:/Dev-Cpp/Lib/libgtk.dll.a" -L"C:/Dev-Cpp/Lib/libgdk.dll.a" -mwindows C:/Dev-Cpp/Lib/libz.a C:/Dev-Cpp/Lib/libglib-2.0.dll.a C:/Dev-Cpp/Lib/libgtk.dll.a C:/Dev-Cpp/Lib/libgdk.dll.a
INCS = -I"C:/Dev-Cpp/include" -I"C:/Dev-Cpp/INCLUDE/GDK" -I"C:/Dev-Cpp/include/gtk"
CXXINCS = -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" -I"C:/Dev-Cpp/INCLUDE/GDK" -I"C:/Dev-Cpp/include/gtk"
BIN = Project1.exe
CXXFLAGS = $(CXXINCS)
CFLAGS = $(INCS) -mwindows -mno-cygwin -fnative-struct -DHAVE_CONFIG_H
RM = rm -f
.PHONY: all all-before all-after clean clean-custom
all: all-before Project1.exe all-after
clean: clean-custom
${RM} $(OBJ) $(BIN)
$(BIN): $(OBJ)
$(CC) $(LINKOBJ) -o "Project1.exe" $(LIBS)
support.o: support.c
$(CC) -c support.c -o support.o $(CFLAGS)
callbacks.o: callbacks.c
$(CC) -c callbacks.c -o callbacks.o $(CFLAGS)
interface.o: interface.c
$(CC) -c interface.c -o interface.o $(CFLAGS)
main.o: main.c
$(CC) -c main.c -o main.o $(CFLAGS)
;=========================================================================
Many thanks: Barni
I have no idea what -fnative-struct might be intended to do, it is not mentioned in the GCC documentation. Sorry.