Warning message

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • simuumar
    New Member
    • Nov 2008
    • 6

    Warning message

    When I compile the program I have the follwing message

    In function 'int main()'

    ignoring #pragma omp for

    The code is following

    #ifdef _OPENMP
    #include <omp.h>
    #endif
    int main()
    {
    # pragma omp for
    {
    for (int i=0; i<=10 i++)
    {}
    }
    return o;
    can somebody help me.

    }
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    And what is "#pragma omp for" supposed to mean? Unknown pragmas are
    supposed to be ignored by the compiler.

    kind regards,

    Jos

    ps. I removed your email address for your own privacy.

    Comment

    • simuumar
      New Member
      • Nov 2008
      • 6

      #3
      How I can execute the omp parallel directive
      can you please mentioned what is the mistake.

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by simuumar
        How I can execute the omp parallel directive
        can you please mentioned what is the mistake.
        I'm sure your manual describes all the nitty-gritty details about its own compiler's
        pragma directives.

        kind regards,

        Jos

        Comment

        • Banfa
          Recognized Expert Expert
          • Feb 2006
          • 9067

          #5
          simuumar, are you aware that #pragma is a directive to a specific compiler on a specific platform. The standard says little about them except that, as Jos says, unknown pragmas should be ignored by any compiler.

          Part from that there is most no relationship between pragmas on 1 platform and another. Anything we could have to say about the pragmas we know would be completely irrelevant to your unknown platform.

          To know how the pragam you have used or the pragma you want to use works you will need to read the documentation for your compiler/platform.

          Comment

          • simuumar
            New Member
            • Nov 2008
            • 6

            #6
            Can u please send me any complete example.
            please.so that i can understand.

            Comment

            • Banfa
              Recognized Expert Expert
              • Feb 2006
              • 9067

              #7
              Here is an example

              #pragma once

              For the Microsoft Compiler (Visual C++/Visual Studio) when used in a header (.h) file it ensures that the file is only included into the code once in a way that is marginally more efficient than using #ifndef inclusion protection and speeds up complication marginally.

              Some other compilers may support that pragma but there is no guarantee.

              Comment

              • simuumar
                New Member
                • Nov 2008
                • 6

                #8
                Originally posted by Banfa
                Here is an example

                #pragma once

                For the Microsoft Compiler (Visual C++/Visual Studio) when used in a header (.h) file it ensures that the file is only included into the code once in a way that is marginally more efficient than using #ifndef inclusion protection and speeds up complication marginally.

                Some other compilers may support that pragma but there is no guarantee.

                # ifdef _OPENMP
                # include < omp.h >
                # endif
                int main()
                {
                int i,id ;
                #pragma once
                {
                for (i = 0; i<4; ++i )
                {
                int id = omp_get_thread_ num ();

                return 0;

                }
                }
                }


                I am compiling the above code but its not working.Please help.
                or correct the above please

                Comment

                • JosAH
                  Recognized Expert MVP
                  • Mar 2007
                  • 11453

                  #9
                  Banfa gave you an example for a compiler bound pragma; not something to be
                  copied/pasted (to the wrong location) and to be compiled without any understanding.

                  kind regards,

                  Jos

                  Comment

                  • simuumar
                    New Member
                    • Nov 2008
                    • 6

                    #10
                    Originally posted by JosAH
                    Banfa gave you an example for a compiler bound pragma; not something to be
                    copied/pasted (to the wrong location) and to be compiled without any understanding.

                    kind regards,

                    Jos
                    Can I have some program using pragma

                    Comment

                    • JosAH
                      Recognized Expert MVP
                      • Mar 2007
                      • 11453

                      #11
                      Originally posted by simuumar
                      Can I have some program using pragma
                      No; start reading your compiler manual.

                      Jos

                      ps. and don't repeat your same question over and over again. We have given
                      you the answers you need.

                      Comment

                      • simuumar
                        New Member
                        • Nov 2008
                        • 6

                        #12
                        Originally posted by JosAH
                        No; start reading your compiler manual.

                        Jos

                        ps. and don't repeat your same question over and over again. We have given
                        you the answers you need.


                        so can u provide me some understanding. Atleast i can run the progrma please.Then I will understand automatically.

                        Comment

                        • JosAH
                          Recognized Expert MVP
                          • Mar 2007
                          • 11453

                          #13
                          Originally posted by simuumar
                          so can u provide me some understanding. Atleast i can run the progrma please.Then I will understand automatically.
                          Banfa already gave you a perfect example: '#pragma once'; it belongs in a .h file
                          and not in a .c or .cpp file as was clearly explained. For other pragmas read your
                          fine compiler manual; I'm sure you'll find some. All pragmas are tied to a compiler,
                          i.e. they don't make sense for another compiler and are ignored, possibly after
                          issueing a warning message.

                          kind regards,

                          Jos

                          Comment

                          • donbock
                            Recognized Expert Top Contributor
                            • Mar 2008
                            • 2427

                            #14
                            What compiler (version/vendor) are you using. Pragmas are compiler-specific. The examples you've been given are only valid for the compilers used by the respondents. It is truly impossible for anybody here to guess which pragmas are supported by your compiler. If you tell us your compiler vendor then there is a chance we can help you -- but there are no guarantees: you might be using a compiler unfamiliar to us.

                            By the way, are you using the same compiler that was used to originally write the code? If not, then you're porting the code to a new build environment. With careful discipline, C code can be written so that it ports uneventfully to another environment. On the other hand, C code can be written in ways that are a nightmare to port. Pragmas are one of the most nonportable parts of the language. If your code contains pragmas then I wonder if it contains other dependencies on nonportable features.

                            Comment

                            • RedSon
                              Recognized Expert Expert
                              • Jan 2007
                              • 4980

                              #15
                              Originally posted by simuumar
                              so can u provide me some understanding. Atleast i can run the progrma please.Then I will understand automatically.
                              No one can provide you with some understanding, it is your responsibility to take what we have told you and learn from it. You will not understand automatically if someone wrote a program for you that has some pragma statements in it because you clearly don't have the slightest clue what pragma means.

                              Here is some information on the Microsoft compiler's pragma directives (http://msdn.microsoft.com/en-us/libr...05(VS.71).aspx) you can use it to get an idea of what they are but if you are not using Microsoft's compiler these directives will be useless for you.

                              Comment

                              Working...