Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.
2464 Discussions

VC++ language CLR windows form with TBB? (error C2695)

anine
Beginner
495 Views

I meet a question. When I write a TBB program in console mode. It is running normally.But when I write a TBB program in clr windows form(this program is the same code under clr windows form and console mode). The compiler appear in the wrong information(error C2695).

" \Program Files\Intel\TBB\2.1\include\tbb\parallel_for.h(59) : error C2695
function1' overriding virtual function differs from 'function2' only by calling convention".
Where function1 is 'start_for::note_affinity' and function2 is 'tbb::task::note_affinity'.

This problem confuse me. Does any reason cause this question? How should I solve it?

Thank you

0 Kudos
3 Replies
Andrey_Marochko
New Contributor III
495 Views

I'm not completely sure that this will help, but for the sake of experiment try to do the following:

  • Open file "tbb/parallel_for.h"
  • Find the line:
    /*override*/ void note_affinity( affinity_id id ) {
  • Change it to
    /*override*/ void __TBB_EXPORTED_METHOD note_affinity( affinity_id id ) {
  • Save the changed file
  • Rebuild your application

And, please, write us if it helped or not.

0 Kudos
anine
Beginner
495 Views
Thanks for your answer. I followed your method to change codes in tbb/parallel_for.h. There is still a mistake(C3641). This mistake is a question about '/clr:pure' and 'calling_convention'.
I only hope to change the following procedure from CLR console mode into CLR window form.
I am so unexpected that the problem is happen.
Maybe I have not noticed some details of CLR windows form.
class Average{
float* input;
float* output;
size_t size;
public:
void operator () (const blocked_range & r) const {
for(size_t i = r.begin(); i != r.end(); i++){
if(i == 0)
output = (input + input + input[i+1])/3;
else if(i == (size-1))
output = (input[i-1] + input + input)/3;
else
output = (input[i-1] + input + input[i+1])/3;

}
} // end operator()
Average(float _i[], size_t _s, float _o[]) : input(_i), size(_s), output(_o) {} //constructor + initial setup
};

0 Kudos
Andrey_Marochko
New Contributor III
495 Views

OK, I see what was the reason of your problem. You attempt to compile your .Net app in the "/clr:pure" mode. This won't work with the native library like TBB. Use the simple "/clr" option to compile your project. (And do not forget to remove that __TBB_EXPORTED_METOD qualifier from the "parallel_for.h" you've added recently.)

0 Kudos
Reply