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. Managed C++/CLI
  4. extern "C" in C++/CLI?

extern "C" in C++/CLI?

Scheduled Pinned Locked Moved Managed C++/CLI
c++dotnetquestion
2 Posts 2 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.
  • D Offline
    D Offline
    Don Rolando
    wrote on last edited by
    #1

    Short questions: Can I include old C code? So far I was used to have an extern "C" block around the corresponding include-instructions. Is this still possible in C++/CLI, or does "managed C++" not allow any C code at all? At least the compiler tells me that the file I wanted to include cannot be compiled with /clr option. ;-)

    L 1 Reply Last reply
    0
    • D Don Rolando

      Short questions: Can I include old C code? So far I was used to have an extern "C" block around the corresponding include-instructions. Is this still possible in C++/CLI, or does "managed C++" not allow any C code at all? At least the compiler tells me that the file I wanted to include cannot be compiled with /clr option. ;-)

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      Don Rolando wrote:

      Short questions: Can I include old C code?

      Yes

      Don Rolando wrote:

      So far I was used to have an extern "C" block around the corresponding include-instructions.

      I don't know what you mean but I just added these, compiled and executed my project without error.

      extern "C" int getfoo(){ return 12; }
      extern "C" int getbar(){ return 14; }

      int _tmain(int argc, _TCHAR* argv[])
      {

      System::Console::WriteLine("Mixed Mode Console (v 1.0)");
          System::Console::WriteLine(System::String::Format("foo: {0}", getfoo()));
         
          System::ConsoleKeyInfo ki = System::Console::ReadKey();
          return 0;
      }

      led mike

      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