calling C++ methods from C -


So it has been a while since I've used C directly and I have a project where I work on I am at C ++ in an API. Most of these methods are just C anyway, and all return values ​​are C structures. Except one. One method gives me the vector & lt; String & gt; needs to be returned. Now my question is, what is qualified with C ++ methods / libraries / C? I will ask because I do not know people who are using APIs are going to write in C or C ++, and I think I should just return the C structures. This is the reason why I have to go back to a four ** , that will not be required.

I hope that made sense, if not:

Tl; Dr. Version - I can do this if it gives a C structure, and call a C ++ method from C if that is the best (only?) Equal return vector & lt is the value, string & gt; -> Four ** ?

Update: C ++ methods are only global methods, no class or object-oriented stuff. The only thing is that C ++ is specific to my vector question other than some stringstreams

No, can not use the C ++ features which are also not available in C. However, C code can indirectly use C ++ code. For example, if you can apply a function using C ++, and so much that uses signature you can use the opaque type in the interface zero * , but Implementation uses a C ++ class.

equal to vector & lt; String & gt; Perhaps it is close to C:

  typingf const char * c_string_type; Typedef struct c_string_array {c_string_type * c_strings; Int c_strings_count; } C_string_array_t;  

With the opaque type, you will have something on the lines of:

  typedef zero * c_string_array_t; Int c_string_array_length (c_string_array_t array); Const char * c_string_array_get (c_string_array_t array, int index);  

You can secretly insert (in C ++ implementation) std :: vector * to zero *.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -