ubuntu:python调用c生成so文件出错

bfs.cpp:11:15: error: expected constructor, destructor, or type conversion before ‘(’ token
     __declspec(dllexport)

windows到linux的转换:

windows下:

#include 
#include 
#include 
#include 

using namespace std;

#define FF(a,b) for(a=0;a=0 && y=0)
		return true;
	return false;
}

void bfs(int *img,int x,int y){
	queue q;
	vector v;
	q.push(Pt(x,y));
	bool flag=1;
	int i;
	while(!q.empty()){
		Pt pt=q.front();
		q.pop();
		vis[MAP(x,y)]=1;
		int cx=pt.x,cy=pt.y;
		FF(i,4){
			int tx=cx+dx[i];
			int ty=cy+dy[i];
			if(legal(tx,ty)){
				if(img[MAP(tx,ty)]==0 && vis[MAP(tx,ty)]==0){
					q.push(Pt(tx,ty));
					v.push_back(Pt(tx,ty));
					vis[MAP(tx,ty)]=1;
				}
			}else{
				flag=0;
			}
		}
		if(flag){
			int sz=v.size();
			FF(i,sz){
				int & tx=v[i].x;
				int & ty=v[i].y;
				img[MAP(tx,ty)]=255;
			}
		}
	}
}

void fillHole(int * img,int X,int Y){
	x_s=X,y_s=Y;
	int i,j;
	FF(i,x_s)FF(j,x_s)if(!vis[MAP(i,j)]){
		bfs(img,i,j);
	}
}

//int main() {
//	return 0;
//}

 

linux下的使用:

#include 
#include 
#include 
#include 

using namespace std;

#define FF(a,b) for(a=0;a=0 && y=0)
		return true;
	return false;
}

void bfs(int *img,int x,int y){
	queue q;
	vector v;
	q.push(Pt(x,y));
	bool flag=1;
	int i;
	while(!q.empty()){
		Pt pt=q.front();
		q.pop();
		vis[MAP(x,y)]=1;
		int cx=pt.x,cy=pt.y;
		FF(i,4){
			int tx=cx+dx[i];
			int ty=cy+dy[i];
			if(legal(tx,ty)){
				if(img[MAP(tx,ty)]==0 && vis[MAP(tx,ty)]==0){
					q.push(Pt(tx,ty));
					v.push_back(Pt(tx,ty));
					vis[MAP(tx,ty)]=1;
				}
			}else{
				flag=0;
			}
		}
		if(flag){
			int sz=v.size();
			FF(i,sz){
				int & tx=v[i].x;
				int & ty=v[i].y;
				img[MAP(tx,ty)]=255;
			}
		}
	}
}

void fillHole(int * img,int X,int Y){
	x_s=X,y_s=Y;
	int i,j;
	FF(i,x_s)FF(j,x_s)if(!vis[MAP(i,j)]){
		bfs(img,i,j);
	}
}

//int main() {
//	return 0;
//}

reference:

https://www.cnblogs.com/TQCAI/p/8886983.html

 

 

 

你可能感兴趣的:(c++,Ubuntu)