Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

c - Compiling a GTK3 program in Visual Studio 2012

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...