[Bf-committers] How to mix C and C++ in Blender
Jürgen Herrmann
shadowrom at me.com
Tue Jun 18 23:29:15 CEST 2013
Hi Alexander,
I personally don't like this, but it is possible:
http://stackoverflow.com/questions/7281441/elegantly-call-c-from-c
http://stackoverflow.com/questions/2399344/calling-c-code-from-c
http://stackoverflow.com/questions/2744181/how-to-call-c-function-from-c
Google is your friend ;) Sometimes...
I don't know exactly what the blender coding conventions say about this, but I would consider this bad style, because you have to introduce wrappers that might easily break when a external lib is updated.
I am curious what the other devs say ;)
/Jürgen
Am 18.06.2013 um 23:02 schrieb Alexander Pinzon Fernandez <apinzonf at gmail.com>:
> Hi all.
>
> I am working on Bmesh operator for perform laplacian editing for sketch
> mesh gsoc project.
>
> If the library to solve the linear system is SuperLU and Eigen3 for matrix
> operations, then I must learn how to mix C code (SuperLU) and C ++ (Eigen3)
> in Blender. (elegant and organized way).
>
> I have c code file in
> source\blender\bmesh\operators\bmo_deform_laplacian.c
> in bmo_deform_laplacian.c i call several c++ functions (ej. au = ftest(4
> ,5);) declare in bmo_deform_utils.h and implemented in
> bmo_deform_utils.cpp.
>
> this two files are in source\blender\bmesh\operators\
>
> What are the directories where the files should put bmo_deform_utils.h
> and bmo_deform_utils.cpp?
> What are policies and style guides in Blender to mix C code and C ++?
>
> Example
>
> bmo_deform_laplacian.c
> //////////////////////////////////////
> ....
> #Include "bmo_deform_utils.h"
> ...
> au = ftest(4 ,5);
> ...
> ///////////////////////////////////////
>
> bmo_deform_utils.h
> ///////////////////////////////////////
> #ifndef __BMO_DEFORM_UTILS_H__
> #define __BMO_DEFORM_UTILS_H__
>
>
> #ifdef __cplusplus
> extern "C" {
> #endif
>
> int ftest(int x, int y);
>
> #ifdef __cplusplus
> };
> #endif
>
> #endif //__BMO_DEFORM_UTILS_H__
> ///////////////////////////////////////
>
> bmo_deform_utils.cpp
> ///////////////////////////////////////////
>
> #include "bmo_deform_utils.h"
>
> class ABC{
> public:
> int a,b;
> ABC(int ax, int by ){
> a = ax;
> b = by;
> }
> int fsum(){
> return a + b;
> }
> };
>
> int ftest(int x, int y){
> ABC A(x, y);
> return A.fsum();
> }
> ///////////////////////////////////////////
>
> Thanks in advance.
>
> Att
> Alexander Pinzon Fernandez
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> http://lists.blender.org/mailman/listinfo/bf-committers
More information about the Bf-committers
mailing list