• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Storyyeller

Code::Blocks compiler options

6 posts in this topic

I am making a game in C++ with Code::Blocks. I noticed that I was often getting bugs due to forgetting to return a value from a function, so I tried to make the compiler treat this as an error. However, I can't figure out how to do it. I tried putting -Werror=return-type under Other Options on the Build Options menu, but now it refuses to build at all. -------------- Build: Debug in Pickory --------------- mingw32-g++.exe -Wall -Werror=return-type -g -Wall -Wno-reorder -I..\Pickory -I..\zHeaders\BOX2D_21 -I..\zHeaders -IC:\ActiveProjects\zHeaders -c C:\ActiveProjects\Pickory\main.cpp -o obj\Debug\main.o cc1plus.exe: error: unrecognized command line option "-Werror=return-type" Process terminated with status 1 (0 minutes, 0 seconds) 0 errors, 0 warnings
0

Share this post


Link to post
Share on other sites
There is no such option, try running cc1plus with --help to get possible options listed. Also, why aren't warnings enough? With -Wall switch surely there are warnings when there is no return value from a function.
0

Share this post


Link to post
Share on other sites
Quote:
Original post by Storyyeller
I am making a game in C++ with Code::Blocks. I noticed that I was often getting bugs due to forgetting to return a value from a function, so I tried to make the compiler treat this as an error.
However, I can't figure out how to do it.

I tried putting -Werror=return-type under Other Options on the Build Options menu, but now it refuses to build at all.



-------------- Build: Debug in Pickory ---------------

mingw32-g++.exe -Wall -Werror=return-type -g -Wall -Wno-reorder -I..\Pickory -I..\zHeaders\BOX2D_21 -I..\zHeaders -IC:\ActiveProjects\zHeaders -c C:\ActiveProjects\Pickory\main.cpp -o obj\Debug\main.o
cc1plus.exe: error: unrecognized command line option "-Werror=return-type"
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings


Code::Blocks is not a compiler, but an IDE that supports, beneath other, MinGW, which in turn is the windows port of GCC. Hence, you will find all supported command line options at http://gcc.gnu.org/onlinedocs/gcc/Invoking-GCC.html#Invoking-GCC, there you'll find Warning-Options, and then, there is "-Werror" to treat warnings as errors, and as mrjones mentioned, "-Wall" to enable all standard options. Then there is "-Wextra", to get even more warnings. And to be even surer, you can also use "-pedantic", to make it even more strict vs. ISO, and "-pedantic-errors", to emit errors for -pedantic related warnings.

Oh, and you can save yourself from hardcoding options:
0

Share this post


Link to post
Share on other sites
-Werror works, but I wanted to treat only one specific type of warning as an error.

So I tried to use the -Werror= option mentioned at http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#Warning-Options but it didn't work.


Quote:

-Werror=
Make the specified warning into an error. The specifier for a warning is appended, for example -Werror=switch turns the warnings controlled by -Wswitch into errors. This switch takes a negative form, to be used to negate -Werror for specific warnings, for example -Wno-error=switch makes -Wswitch warnings not be errors, even when -Werror is in effect. You can use the -fdiagnostics-show-option option to have each controllable warning amended with the option which controls it, to determine what to use with this option.



I don't want it to treat all warnings as errors, because I am using Box2d, which has tons of spurious warnings in its headers, and I don't feel like rewriting the whole library myself.
0

Share this post


Link to post
Share on other sites
I guess return-type is not about not returning from a function, but about misuse of the return-type, e.g. return .0f where the return type is actually int.

I don't know if you can disable/enable that mistake you look for in particular, but what is wrong with -Wall? It gives you a list of all warnings, which are there for a reason. Then, in case there are 159467821345 errors, you could still text-search the list.
0

Share this post


Link to post
Share on other sites
Looking through hundreds of warnings every single time I make a change to the program is kind of a pain.

It would be so much simpler to get it to automatically stop the build process when it encounters certain warnings.
0

Share this post


Link to post
Share on other sites
Quote:
Original post by Storyyeller
Looking through hundreds of warnings every single time I make a change to the program is kind of a pain.

Quote:
Original post by phresnel
Then, in case there are 159467821345 errors, you could still text-search the list.




Quote:
It would be so much simpler to get it to automatically stop the build process when it encounters certain warnings.

While it seems you can enable/disable your particular warning wish, you can also -Werror -Wfatal-errors and fix warnings step by step.

Why exactly don't you want to fix all warnings? It is annoying, but something you should always do, if you are interested in good code (and good programmers are interested in good code :)).


edit: Ah, I was so wrong about return-type.

Test this snippet with -Werror=return-type -Wfatal-errors (== treat no return type as error, abort upon error)
#include <stdio.h>
int u () {
printf("%d", .5f); // will give you a format warning
} // gives you an error for missing return, and stops

int v () {
printf("%d", .5f); // nothing, compilation stopped already
} // nothing, compilation stopped already



I also see now most of your warnings come from Box2d. In that case, there would be those pragmas, where you can nitpick-disable some warnings (#pragma ... #include ... #pragma):

#pragma GCC diagnostic ignored "-Wformat"
int u () {
printf("%d", .5f); // nothing
return 0;
}
#pragma GCC diagnostic enable "-Wformat"



edit2: And there is -fdiagnostics-show-option, which will make gcc print the proper switch for each diagnostic it emits. You could use that option to see which warnings are produced by Box2d, and then disable them using above pragma.



[Edited by - phresnel on January 19, 2010 2:22:48 AM]
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0