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. C / C++ / MFC
  4. C1189: #error : MFC requires C++ compilation (use a .cpp suffix)

C1189: #error : MFC requires C++ compilation (use a .cpp suffix)

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpcsharpvisual-studio
4 Posts 3 Posters 0 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.
  • Z Offline
    Z Offline
    zakarias
    wrote on last edited by
    #1

    Hi! I am trying to use CString in my project, after including the file afx.h I received the following error:"G:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\afx.h(15) : fatal error C1189: #error : MFC requires C++ compilation (use a .cpp suffix)". I went to project->settings->C/C++ and I choosed "category"->precompiled headers->use precompiled headers and I added stdafx.h I don't understand! the error is still there! Please help!!:rose:

    V P 2 Replies Last reply
    0
    • Z zakarias

      Hi! I am trying to use CString in my project, after including the file afx.h I received the following error:"G:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\afx.h(15) : fatal error C1189: #error : MFC requires C++ compilation (use a .cpp suffix)". I went to project->settings->C/C++ and I choosed "category"->precompiled headers->use precompiled headers and I added stdafx.h I don't understand! the error is still there! Please help!!:rose:

      V Offline
      V Offline
      valikac
      wrote on last edited by
      #2

      Include windows.h. Kuphryn

      1 Reply Last reply
      0
      • Z zakarias

        Hi! I am trying to use CString in my project, after including the file afx.h I received the following error:"G:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\afx.h(15) : fatal error C1189: #error : MFC requires C++ compilation (use a .cpp suffix)". I went to project->settings->C/C++ and I choosed "category"->precompiled headers->use precompiled headers and I added stdafx.h I don't understand! the error is still there! Please help!!:rose:

        P Offline
        P Offline
        peterchen
        wrote on last edited by
        #3

        One of the files that include afx.h has a .c or similar ending (VC++ decides whether to use it's C or C++ compiler based on the file extension). Using CString is not as easy as just #including stdafx.h - you need to link with MFC, change compile settings, etc, and get a whole lot of dependencies. You can either use WTL[^], which comes with a perfectly compatible CString class, or "extract" the CString class from the MFC sources (again, complicated, but there#s a Macro on CodeGuru that can do that. Lost the link though...)


        "Der Geist des Kriegers ist erwacht / Ich hab die Macht" StS
        sighist | Agile Programming | doxygen

        Z 1 Reply Last reply
        0
        • P peterchen

          One of the files that include afx.h has a .c or similar ending (VC++ decides whether to use it's C or C++ compiler based on the file extension). Using CString is not as easy as just #including stdafx.h - you need to link with MFC, change compile settings, etc, and get a whole lot of dependencies. You can either use WTL[^], which comes with a perfectly compatible CString class, or "extract" the CString class from the MFC sources (again, complicated, but there#s a Macro on CodeGuru that can do that. Lost the link though...)


          "Der Geist des Kriegers ist erwacht / Ich hab die Macht" StS
          sighist | Agile Programming | doxygen

          Z Offline
          Z Offline
          zakarias
          wrote on last edited by
          #4

          I tried to link with MFC, change compile settings...etc but many other errors appeared...I still don't know how to convert from C to C++...beginner's problem! Maybe I will create a dll with all the MFC functions that I'll need and I'll call them from my application. Thanks a lot for your help.

          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