[Bf-committers] How to mix C and C++ in Blender
Alexander Pinzon Fernandez
apinzonf at gmail.com
Tue Jun 18 23:02:47 CEST 2013
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
More information about the Bf-committers
mailing list