Rohan Maity
05/26/2019, 2:10 PMcinterop
for stack
header file in c++. I encountered Exception in thread "main" java.lang.Error: /usr/include/c++/7/bits/functexcept.h:42:1: error: unknown type name 'namespace'.
Is kotlin/native unable to determine namespace
?olonho
05/26/2019, 3:13 PMRohan Maity
05/26/2019, 3:15 PMmsink
05/26/2019, 3:19 PMRohan Maity
05/26/2019, 3:21 PMmsink
05/26/2019, 3:24 PMRohan Maity
05/26/2019, 3:31 PM// *.h file
// ...
#ifdef __cplusplus
#define EXTERNC extern "C"
#else
#define EXTERNC
#endif
typedef void* mylibrary_mytype_t;
EXTERNC mylibrary_mytype_t mylibrary_mytype_init();
EXTERNC void mylibrary_mytype_destroy(mylibrary_mytype_t mytype);
EXTERNC void mylibrary_mytype_doit(mylibrary_mytype_t self, int param);
#undef EXTERNC
// ...
// *.cpp file
mylibrary_mytype_t mylibrary_mytype_init() {
return new MyType;
}
void mylibrary_mytype_destroy(mylibrary_mytype_t untyped_ptr) {
MyType* typed_ptr = static_cast<MyType*>(untyped_ptr);
delete typed_ptr;
}
void mylibrary_mytype_doit(mylibrary_mytype_t untyped_self, int param) {
MyType* typed_self = static_cast<MyType*>(untyped_self);
typed_self->doIt(param);
}
msink
05/26/2019, 3:45 PMRohan Maity
05/26/2019, 4:10 PMstl_stack.h
and its throwing exception for namespace
.
So do I have to create my own stl_stack.h
& using extern refer the C++ implementation ?msink
05/26/2019, 4:20 PMstruct stl_stack;
- then it can be used for function parameters as pointer - and implement it in C++ part?Rohan Maity
05/26/2019, 4:24 PMoriginal stl_stack.h
is also only declaration and some stl_stack.cpp
is it's implementation (AFAIU). So I will create my own stl_stack.h
and use that stl_stack.cpp
Rohan Maity
05/27/2019, 4:51 AM//.... *.h file
#ifdef __cplusplus
#define EXTERNC extern "C"
#else
#define EXTERNC
#endif
typedef struct stl_stack;
typdef void* T
EXTERNC void push(T item);
EXTERNC T pop();
EXTERNC int size();
// ...... stl_stack.cpp
#include<stack>
using namespace std;
template <typename T>
stack<T> s;
void push(T item){
s.push(item);
}
T pop(){
s.pop()
}
msink
05/27/2019, 4:58 AMRohan Maity
05/27/2019, 4:59 AMmsink
05/27/2019, 5:34 AMRohan Maity
05/27/2019, 5:46 AM