c++マクロ定義で関数#defineを記述
#include
#include
#include
#include"hello.h"
#ifdef _OPENMP
#include
#endif
#define CHECK(arg){ \
\
cout< 1){
threadnum = atoi(argc[1]);
omp_set_num_threads(threadnum);
}
#pragma omp parallel for reduction(+:_T)
for(int i=0;i<5;i++)
_T += i;
#endif
fun();
CHECK(__FILE__);
CHECK(__LINE__);
cout<<_t checkopenmp="" _check="" cout="" _hello="" world="" return=""/>
hello.h以下:
#ifndef _hello
#define _hello
int max(int a, int b){
return a>b?a:b;
}
typedef struct cigbsegy{
int a;
int b;
int c;
}cigbsegy, SEGY;
#endif
#define _CHECK(arg) \
{ \
cout<
結果:
rongtao@rongtao:~/test$ g++ -o a hello.cpp -fopenmp
rongtao@rongtao:~/test$ ./a 3
fun
CHECK:hello.cpp
CHECK:54
10
_CHECK
10
14
Hello World!
rongtao@rongtao:~/test$