Compiling a GTK3 program in Visual Studio 2012

2020-02-13 05:08发布

问题:

With the release of Gtk 3 for windows I thought of upgrading my Gtk 2 C application to take advantage of the new GtkGrid widget.

The program compiles fine under linux or using MinGW (with codeblocks) under windows, however when I try the same set of files under Visual Studio 2012, giving me 50 or so compilation errors saying gutils.h, gtrashstack.h and gstring.h have a bunch of syntax errors (assuming I only use a basic program, with just a gtk_init and gtk_main).

Visual Studio handled gtk2 very well. Why is it refusing to compile with gtk3? Any way to get it to work with it? As much as I love Code::Blocks, external powers force me to keep my code VS2012-compatible...

EDIT: I created a repository with a simple gtk3 program and preconfigured project files for VS2012 and Codeblocks. https://github.com/The-J-Person/Example-gtk3-vs2012-project

EDIT 2: Here's a list of the compilation errors given by VS2012: http://pastebin.com/ThZpwVmg

回答1:

There is now an answer on the GTK mailing list.

In gutils.h lines 82 and 122, and in gstring.h line 129, change "static inline" to "static __inline". Alternatively add a PreprocessorDefinition to the project file to define "inline" as "__inline".

https://mail.gnome.org/archives/gtk-list/2014-January/msg00011.html

That allowed my project to work just fine.