You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Premake在VS2019中为C/C++命令行添加/FS选项

How to Add the /FS Compiler Option via Premake5 for Visual Studio 2019

Got it! To add the /FS compiler option (which maps directly to the Properties -> C/C++ -> Command Line -> Additional Options setting in Visual Studio 2019) to your project, you just need to add a buildoptions entry in your project configuration. It's best to wrap it in a filter to ensure it only applies to Visual Studio generators, so it doesn't interfere with other compilers like GCC or Clang.

Here's your modified premake.lua with the necessary change:

workspace "test_refactor_edit_control_01"
platforms { "Win32", "64" }
configurations { "Debug", "Release" }
filter "platforms:Win32"
    architecture "x86"
filter "platforms:64"
    architecture "x64"

project "test_refactor_edit_control_01"
    location "test_refactor_edit_control_01"
    kind "WindowedApp"
    language "C++"
    staticruntime "Off"
    targetdir ("bin/" .. outputdir .. "/%{prj.name}")
    objdir ("bin-int/" .. outputdir .. "/%{prj.name}")
    
    -- Add /FS compiler option for Visual Studio only
    filter "action:vs*"
        buildoptions "/FS"
    
    -- Rest of your configuration goes here
    ...

Quick Explanation:

  • buildoptions "/FS" directly injects the /FS flag into the C/C++ command line additional options of your Visual Studio project, exactly like setting it manually in the IDE.
  • The filter "action:vs*" ensures this setting only applies to any Visual Studio generator (including VS2019), keeping your configuration cross-compiler friendly. If your project is only targeting Visual Studio, you can skip the filter and just add buildoptions "/FS" directly under the project block.

内容的提问来源于stack exchange,提问作者Ivan Ambic

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.06 10:08:14