Examples of UDFs using C++


#1

I have been able to use and extend the example UDFs with a few minor tweaks. However, I wanted to know if there are any examples of implementing UDFs with C++?

It would be great if the same udfexample.c were setup as a pure udfexample.cpp example with the appropriate directions for compiling and showing what was necessary to pass the same information back and forth using C++ datatypes as well as implementing UdfLog functionality, etc using pure c++ functionality.

Thanks!


#2

you might use such declaration for you C++ function like in udfexample.cpp

@@ -23,7 +23,7 @@
 #define snprintf _snprintf
 #define DLLEXPORT __declspec(dllexport)
 #else
-#define DLLEXPORT
+#define DLLEXPORT extern "C"
 #endif

this way it will compiles well as C++ code g++ -fPIC -shared -o udfexample.so ../src/udfexample.cpp and later could be used as UDF with daemon


#3

Thanks. I but that part I already had. It was the casting of c++ variables that concerned me. But, I have been able to get that to work.

Thanks again.