Is there a way to allow implicit conversions in C ++?

I need to use chunks of a C library in a C ++ / CLI project. I made the c files compile as C ++, the problem is the library uses a lot of implicit enums for whole comparisons that C ++ doesn't allow. Now I could just drop all of them, but I would like to get the result without modifying the source code of the library if possible (since the library is still under development and I would like to be able to play plp-pn). Is there a way to allow C ++ to implicitly convert these enums?

+3


source to share


1 answer


Answer pedant No .

The C ++ standard is stricter in this regard than the C standard, and implicit integer-to-count or to- void*

to- casts T*

don't work out of the box.




You have a couple of solutions ahead of you:

  • your compiler may have such a switch, it rarely happens that the compiler switches to run non-standard behavior (often referred to as "functions"); I don't know of such a switch, but there are so many ...
  • you can compile the C code as C (perhaps linking to a separate library if needed)
  • you can edit your C code so that it compiles like C and C ++
  • and finally, since this is a development library, you can ask the authors to make sure their code compiles as C and C ++
+1


source







All Articles