Building Visual Studio solution with C and C++


I’m wondering if I can add a C file to a C++ project. I use premake5 and conan to get the dependencies and build the solution but every file I’ve used so far is C++. Now, I need a C file that has a kdtree that I need to make new features in my engine. But I don’t know if I can work with both C and C++ in one project or how to do it. This is my lua definition for the project. What can I do to add one C file to the project?

project"Particles"

  kind "ConsoleApp"
  language "C++"
  targetdir "../build/%{prj.name}/%{cfg.buildcfg}"
  includedirs { "../include", "../deps/include", "../include/engine", "../deps/include/stb", "../deps/include/imgui", "../deps/include/tests" }
  conan_config_exec()
  debugargs { _MAIN_SCRIPT_DIR .. "/examples/data" }
  files {
    "../deps/src/**",
    "../deps/include/**",
    "../src/**",
    "../include/**",
    "../tests/particles_test.cpp",
    "../assets/**",
  }
  filter "files:**.obj"
      flags { "ExcludeFromBuild" }

Leave a Reply

Your email address will not be published. Required fields are marked *