The flags function specifies build flags to modify the compiling or linking process.
flags { "flag_list" }
If a project includes multiple calls to flags the lists are concatenated, in the order in which they appear in the script.
Applies To
Solutions, projects, and configurations.
Parameters
flags_list is a list of string flag names; see below for a list of valid flags. The flag values are not case-sensitive. Flags that are not supported by a particular platform or toolset are ignored.
- EnableSSE, EnableSSE2
- Use the SSE instruction sets for floating point math.
- ExtraWarnings
- Sets the compiler's maximum warning level.
- FatalWarnings
- Treat warnings as errors.
- FloatFast
- Enable floating point optimizations at the expense of accuracy.
- FloatStrict
- Improve floating point consistency at the expense of performance.
- Managed
- Enable Managed C++ (.NET).
- MFC
- Enable support for Microsoft Foundation Classes.
- NativeWChar, NoNativeWChar
- Enable or disable support for the wchar data type. If no flag is specified, the toolset default will be used.
- No64BitChecks
- Disable 64-bit portability warnings.
- NoEditAndContinue
- Disable support for Visual Studio's Edit-and-Continue feature.
- NoExceptions
- Disable C++ exception support.
- NoFramePointer
- Disable the generation of stack frame pointers.
- NoIncrementalLink
- Disable support for Visual Studio's incremental linking feature.
- NoImportLib
- Prevent the generation of an import library for a Windows DLL.
- NoManifest
- Prevent the generation of a manifest for Windows executables and shared libraries.
- NoMinimalRebuild
- Disable Visual Studio's minimal rebuild feature.
- NoPCH
- Disable precompiled header support. If not specified, the toolset default behavior will be used. Also see pchheader and pchsource.
- NoRTTI
- Disable C++ runtime type information.
- Optimize
- Perform a balanced set of optimizations.
- OptimizeSize
- Optimize for the smallest file size.
- OptimizeSpeed
- Optimize for the best performance.
- SEH
- Enable structured exception handling.
- StaticRuntime
- Perform a static link against the standard runtime libraries.
- Symbols
- Generate debugging information.
- Unicode
- Enable Unicode strings. If not specified, the default toolset behavior is used.
- Unsafe
- Enable the use of unsafe code in .NET applications.
- WinMain
- Use WinMain() as the program entry point for Windows applications, rather than the default main().
If the existing flags are not sufficient, you can also pass tool-specific arguments directly to the compiler or linker using buildoptions and linkoptions.
Examples
A common configuration: enable debugging symbols in the Debug configuration, and optimize the Release configuration.
configuration "Debug" flags { "Symbols" } configuration "Release" flags { "Optimize" }
You can specify multiple flags.
flags { "Symbols", "ExtraWarnings", "FatalWarnings" }



Can premake modified the symbols file name ( .pdb file) of VC++ project?
@Anonymous: No, currently it can't. If you need this feature, please file a request.
I notice when I use "Symbols" on a NON-OPTIMISED build in VS2005, it uses "Program Database", rather than "Program Database for Edit & Continue".
Is this correct?
Surely it should choose 'pdb for edit & continue' for non-optimised configs, and 'program database' for optimised ones?
Apologies, my mistake... newbie error! :)
So, on Windows (vs2008), if I set flags to be "StaticRuntime", I'll get /MT. If I want /MTd for a debug build, I have to add "Symbols" as well. However, that then gives me /ZI for the program database. When I'm building a library, I want to use /Z7 since it puts all the symbols directly in the library and so I have to put it in with buildoptions. I thus end up with the following warning:
1>cl : Command line warning D9025 : overriding '/ZI' with '/Z7'
Any ideas on a workaround for this situation?
@Anonymous: if you file a feature request (or file it is a bug, your choice) we can look into adding a new flag to support this case.
BTW, if you would ask these questions in the forums, more people would be able to see and respond to it.