CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2010
    Posts
    39

    macro with in a macro

    Is it possible to define a macro with in a macro ? Any trick will do.
    I am trying to do quick conversion of cuda program to open mp by defining some macros at the top:
    Code:
    #define __syncthreads()  #pragma omp barrier
    Thanks

  2. #2
    Join Date
    Jul 2005
    Location
    Netherlands
    Posts
    2,042

    Re: macro with in a macro

    See http://msdn.microsoft.com/en-us/library/d9x1s805.aspx
    Also note that you should not start names with an underscore, as these are reserved for the compiler.
    Cheers, D Drmmr

    Please put [code][/code] tags around your code to preserve indentation and make it more readable.

    As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky

  3. #3
    Join Date
    Sep 2010
    Posts
    39

    Re: macro with in a macro

    Thanks I came up with an inline function solution but yours works too.
    Code:
    //inline void l_barrier() { 
    //	#pragma omp barrier 
    //}
    #define l_barrier() { \
    __pragma(omp barrier) \
    }
    The __syncthreads with double underscores is defined by the cuda compiler (not from me).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured