Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Studio
  4. telling c from cpp files or making VS recognize c as c++

telling c from cpp files or making VS recognize c as c++

Scheduled Pinned Locked Moved Visual Studio
c++visual-studioquestion
5 Posts 2 Posters 38 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Krischu
    wrote on last edited by
    #1

    I downloaded a github project (SimVDI) and tried to compile it under VS 2013 (being the only VS I have). The author named all the files with extension .c. Almost all code is C but in one place the author seemed to let a sloppiness creep in and did some C++-ish thing (auto declaration in for (int i=0...)). I repaired that to C style. But is there a way to make S treat all files with extension .c as C++ files? (rather than nameing them .cpp)?

    L 1 Reply Last reply
    0
    • K Krischu

      I downloaded a github project (SimVDI) and tried to compile it under VS 2013 (being the only VS I have). The author named all the files with extension .c. Almost all code is C but in one place the author seemed to let a sloppiness creep in and did some C++-ish thing (auto declaration in for (int i=0...)). I repaired that to C style. But is there a way to make S treat all files with extension .c as C++ files? (rather than nameing them .cpp)?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Add the /TP option to the compiler settings. See Compiler Options Listed by Category | Microsoft Docs[^].

      K 1 Reply Last reply
      0
      • L Lost User

        Add the /TP option to the compiler settings. See Compiler Options Listed by Category | Microsoft Docs[^].

        K Offline
        K Offline
        Krischu
        wrote on last edited by
        #3

        Thanks. That helped partially. For the file in question it cured the problem. But it fired a cascade of other errors in other files. I choose the project settings and add the /Tp as an additional command line switch, right?

        L 1 Reply Last reply
        0
        • K Krischu

          Thanks. That helped partially. For the file in question it cured the problem. But it fired a cascade of other errors in other files. I choose the project settings and add the /Tp as an additional command line switch, right?

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          No, it is the /TP option (capital P). Please go to the link I gave you to see the difference.

          K 1 Reply Last reply
          0
          • L Lost User

            No, it is the /TP option (capital P). Please go to the link I gave you to see the difference.

            K Offline
            K Offline
            Krischu
            wrote on last edited by
            #5

            OK thanks. Sorry for misunderstanding. It turns out that the author must have had the intention to mark all soource files being C-files (there was the option /TC alreay there). Overriding that with /TP triggers so many errors that I decided to leave in the /TC option, repair the error manually in that one C-file and will contact the author about that.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups