0

I'm trying to use a C based library into my C++ project. The C header files come already with

    extern c {...}

The problem is as soon as I add some includes which are C++11 based (like Thread, Chrono) it won't compile anymore and start complaining about the thread.h or chrono.h files!

I have also tried putting extern C in my includes but this did not help.

The project is in Visualstudio2015.

Any help is greatly appreciated.

  • 1
    You cannot include C++ files into a C program. You *can* do it the other way round and you *can* implement a strictly C header in a C++ program. You should develop the C library as a standalone first. – quamrana Apr 12 '19 at 12:29
  • https://stackoverflow.com/a/16851023/193892 I think you may be helped by this. I also agree with what @quamrana said. – Prof. Falken Apr 12 '19 at 13:12
  • Thanks for commenting. @quamrana Well I am using the C headers inside C++ Project. – user8249217 Apr 12 '19 at 13:21
  • If you stick to calling C code from C++ you will be ok. I have also written an answer to a previous question which might be helpful here: https://stackoverflow.com/a/2203593/4834 – quamrana Apr 12 '19 at 13:22
  • @quamrana you can, only if you restrict yourself to features that exist in both C and C++. – Quentin Apr 12 '19 at 13:29
  • @Quentin: You can, what, exactly? – quamrana Apr 12 '19 at 13:31
  • @quamrana what you described in your first comment (didn't notice the second one, sorry), that is write files compilable as either C or C++. – Quentin Apr 12 '19 at 13:33

0 Answers0