error: function is taken as an micro

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mohi

    error: function is taken as an micro

    hello everyone,

    i use a function called minor to find the minor of an element of a
    matrix ,
    i declare it as :

    float minor(float A[ ][COL],int m,int n,int i,int j);//find the minor
    in A[][]

    and define it later in the file as :


    float minor(float A[][COL],int m,int n,int i,int j)
    {
    if(m==0 ||n==0)//single coloumn or single row
    return 1.0;

    float temp[ROW][COL];//temp matrix used to find mod (will have one row
    and \
    //less than the parent matrix
    int p,p1,q,q1;//indexes
    for(p=0,p1=0;p< =m&& p1<=(m-1);p++,p1++){
    if(p==i){
    p1--;
    continue;//ignore row i
    }
    for(q=0,q1=0;q< =n && q1<=(n-1);q++,q1++){
    if(q==j){
    q1--;
    continue;//ignore coloumn j
    }
    temp[p1][q1]=A[p][q];

    }
    }

    float x= mod(temp,m-1,n-1);//return the determinant of temp
    return x;
    }




    when i compile it using gnu g++ it gives the following error :


    solve_equation. cpp:13:51: error: macro "minor" passed 5 arguments, but
    takes just 1
    solve_equation. cpp:68:49: error: macro "minor" passed 5 arguments, but
    takes just 1
    solve_equation. cpp:76:51: error: macro "minor" passed 5 arguments, but
    takes just 1
    solve_equation. cpp:121:51: error: macro "minor" passed 5 arguments,
    but takes just 1
    solve_equation. cpp:76: error: invalid function declaration


    as it seems the compiler is taking function minor() as macro .....
    but why???
    and how is the function declaration invalid??

    i use gnu g++ on fedora c8........
    thank you

    mohan gupta
  • mlimber

    #2
    Re: error: function is taken as an micro

    On Aug 21, 12:19 pm, mohi <mohangupt...@g mail.comwrote:
    as it seems the compiler is taking function minor() as macro .....
    but why???
    and how is the function declaration invalid??
    That's not a standard macro; it's something specific to your code,
    your system, or third-party libraries. You can #undef it in your
    header:

    #ifdef minor
    # undef minor
    #endif

    Cheers! --M

    Comment

    • Lionel B

      #3
      Re: error: function is taken as an micro

      On Thu, 21 Aug 2008 09:19:40 -0700, mohi wrote:
      hello everyone,
      >
      i use a function called minor to find the minor of an element of a
      matrix ,
      i declare it as :
      >
      float minor(float A[ ][COL],int m,int n,int i,int j);//find the minor in
      A[][]
      [...]
      when i compile it using gnu g++ it gives the following error :
      >
      >
      solve_equation. cpp:13:51: error: macro "minor" passed 5 arguments, but
      takes just 1
      solve_equation. cpp:68:49: error: macro "minor" passed 5 arguments, but
      takes just 1
      solve_equation. cpp:76:51: error: macro "minor" passed 5 arguments, but
      takes just 1
      solve_equation. cpp:121:51: error: macro "minor" passed 5 arguments, but
      takes just 1
      solve_equation. cpp:76: error: invalid function declaration
      >
      >
      as it seems the compiler is taking function minor() as macro ..... but
      why???
      Maybe there really *is* a macro called `minor' defined somewhere? Try
      giving your function a different name and see if it compiles. Or insert
      some code like:

      #ifdef minor
      #error macro minor already defined!
      #endif

      before your function declaration.
      and how is the function declaration invalid??
      It will be invalid if there is a macro `minor' defined at the point of
      declaration, since the preprocessor will substitute the `minor' macro in
      your function declaration before the compiler sees it.

      --
      Lionel B

      Comment

      • mohi

        #4
        Re: error: function is taken as an micro

        On Aug 21, 9:37 pm, Lionel B <m...@privacy.n etwrote:
        On Thu, 21 Aug 2008 09:19:40 -0700, mohi wrote:
        hello everyone,
        >
        i use a function called minor to find the minor of an element of a
        matrix ,
        i declare it as :
        >
        float minor(float A[ ][COL],int m,int n,int i,int j);//find the minor in
        A[][]
        >
        [...]
        >
        >
        >
        when i compile it using gnu g++ it gives the following error :
        >
        solve_equation. cpp:13:51: error: macro "minor" passed 5 arguments, but
        takes just 1
        solve_equation. cpp:68:49: error: macro "minor" passed 5 arguments, but
        takes just 1
        solve_equation. cpp:76:51: error: macro "minor" passed 5 arguments, but
        takes just 1
        solve_equation. cpp:121:51: error: macro "minor" passed 5 arguments, but
        takes just 1
        solve_equation. cpp:76: error: invalid function declaration
        >
        as it seems the compiler is taking function minor() as macro ..... but
        why???
        >
        Maybe there really *is* a macro called `minor' defined somewhere? Try
        giving your function a different name and see if it compiles. Or insert
        some code like:
        >
        #ifdef minor
        #error macro minor already defined!
        #endif
        >
        before your function declaration.
        >
        and how is the function declaration invalid??
        >
        It will be invalid if there is a macro `minor' defined at the point of
        declaration, since the preprocessor will substitute the `minor' macro in
        your function declaration before the compiler sees it.
        >
        --
        Lionel B
        thank you guys ...
        that was the real problem that minor was declared as macro
        somewhere:::

        but i never defined it as an micro and nether am i using any third
        party library ,
        the starting includes and function declarations of my code are as:



        #include<iostre am>
        #include<cmath>
        #include<cstdli b>

        using namespace std;

        #define ROW 20
        #define COL 20


        #ifdef minor
        #undef minor
        #endif

        void get_array(float [ROW][COL],int* ,int* );//get the input in array
        void inverse(float [][COL],int ,int);//inverse the arary
        void multiply(float [][COL],int,int,float [][COL],int,int,float
        result[][COL] );//multiply two array
        float minor(float A[][COL],int m,int n,int i,int j);//find the minor
        in A[][]
        float mod(float A[][COL],int m,int n);
        void transpose(float temp[][COL],int m,int n,float A[][COL]);//find
        trnpos of temp in A
        void display(float A[][COL],int m,int n);//display array A[][]
        void divide(float array[][COL],int m,int n,float value);//divide
        matrix array by
        //value

        (where i now undefined minor) ,,,,but as i know all the standard
        libarray variable are declared with an underscore
        say" __micro "(i know that its not an hard and fast rule though) so
        where could it have been declared ????can it be in cmath????


        thank you
        mohan

        Comment

        • Victor Bazarov

          #5
          Re: error: function is taken as an micro

          mohi wrote:
          [..]
          (where i now undefined minor) ,,,,but as i know all the standard
          libarray variable are declared with an underscore
          say" __micro "(i know that its not an hard and fast rule though) so
          where could it have been declared ????can it be in cmath????
          Don't ask us. There *is no* standard macro or function called "minor".
          If you think it's part of your compiler/library package, RTFM. If you
          think it's some third party thing, search the source files and the
          headers for 'minor' and examine the output thoroughly.

          Compiler implementors and third party library vendors are free to do
          what they want. They are not really obligated to report to you about
          the macros they define. Unfortunately that's the nature of our business
          relationship with them. The easiest work-around for your problem is to
          rename your function.

          V
          --
          Please remove capital 'A's when replying by e-mail
          I do not respond to top-posted replies, please don't ask

          Comment

          • peter koch

            #6
            Re: error: function is taken as an micro

            On 21 Aug., 19:55, Victor Bazarov <v.Abaza...@com Acast.netwrote:
            mohi wrote:
            [..]
            (where i now undefined minor) ,,,,but as i know all the standard
            libarray variable are declared with an underscore
            say" __micro "(i know that its not an hard and fast rule though)   so
            where could it have been declared ????can it be in cmath????
            >
            Don't ask us.  There *is no* standard macro or function called "minor".
              If you think it's part of your compiler/library package, RTFM.  If you
            think it's some third party thing, search the source files and the
            headers for 'minor' and examine the output thoroughly.
            >
            Compiler implementors and third party library vendors are free to do
            what they want.  They are not really obligated to report to you about
            the macros they define.  Unfortunately that's the nature of our business
            relationship with them.  The easiest work-around for your problem is to
            rename your function.
            I have to disagree. If compiler implementors were free to #define
            anything they wanted, the result would be that portability would be
            close to impossible. This is one of the reasons certain names are
            reserved for the implementation, and minor is not one of them.
            I have not checked my draft of the standard, but it would nor surprise
            me, if there was a (perhaps implicit) requirement not to define or use
            such names. Anyway, defining such a name is simply bad programming
            practice. In normal usercode as well, but especially in a standard
            library.

            /Peter

            Comment

            • Rolf Magnus

              #7
              Re: error: function is taken as an micro

              peter koch wrote:
              On 21 Aug., 19:55, Victor Bazarov <v.Abaza...@com Acast.netwrote:
              >mohi wrote:
              [..]
              (where i now undefined minor) ,,,,but as i know all the standard
              libarray variable are declared with an underscore
              say" __micro "(i know that its not an hard and fast rule though)   so
              where could it have been declared ????can it be in cmath????
              >>
              >Don't ask us.  There *is no* standard macro or function called "minor".
              >If you think it's part of your compiler/library package, RTFM.  If you
              >think it's some third party thing, search the source files and the
              >headers for 'minor' and examine the output thoroughly.
              >>
              >Compiler implementors and third party library vendors are free to do
              >what they want.  They are not really obligated to report to you about
              >the macros they define.  Unfortunately that's the nature of our business
              >relationship with them.  The easiest work-around for your problem is to
              >rename your function.
              >
              I have to disagree. If compiler implementors were free to #define
              anything they wanted, the result would be that portability would be
              close to impossible.
              Well, they are. Nobody is bringing those compiler writers to jail that don't
              obey that rule.
              This is one of the reasons certain names are reserved for the
              implementation, and minor is not one of them. I have not checked my draft
              of the standard, but it would nor surprise me, if there was a (perhaps
              implicit) requirement not to define or use such names. Anyway, defining
              such a name is simply bad programming practice. In normal usercode as
              well, but especially in a standard library.
              Maybe the OP didn't use the compiler in ISO C++ mode. Some standard
              libraries offer additional functions as extension.

              Comment

              • peter koch

                #8
                Re: error: function is taken as an micro

                On 21 Aug., 20:29, Rolf Magnus <ramag...@t-online.dewrote:
                peter koch wrote:
                On 21 Aug., 19:55, Victor Bazarov <v.Abaza...@com Acast.netwrote:
                mohi wrote:
                [..]
                (where i now undefined minor) ,,,,but as i know all the standard
                libarray variable are declared with an underscore
                say" __micro "(i know that its not an hard and fast rule though)  so
                where could it have been declared ????can it be in cmath????
                >
                Don't ask us.  There *is no* standard macro or function called "minor".
                If you think it's part of your compiler/library package, RTFM.  If you
                think it's some third party thing, search the source files and the
                headers for 'minor' and examine the output thoroughly.
                >
                Compiler implementors and third party library vendors are free to do
                what they want.  They are not really obligated to report to you about
                the macros they define.  Unfortunately that's the nature of our business
                relationship with them.  The easiest work-around for your problem isto
                rename your function.
                >
                I have to disagree. If compiler implementors were free to #define
                anything they wanted, the result would be that portability would be
                close to impossible.
                >
                Well, they are. Nobody is bringing those compiler writers to jail that don't
                obey that rule.
                >
                This is one of the reasons certain names are reserved for the
                implementation, and minor is not one of them. I have not checked my draft
                of the standard, but it would nor surprise me, if there was a (perhaps
                implicit) requirement not to define or use such names. Anyway, defining
                such a name is simply bad programming practice. In normal usercode as
                well, but especially in a standard library.
                >
                Maybe the OP didn't use the compiler in ISO C++ mode. Some standard
                libraries offer additional functions as extension.
                This is correct, of course. Still having a #define micro in a C++
                standard library is to me an indication of mediocre software
                engineering. Still, I know nothing about the compiler and the library,
                so perhaps I should watch out?

                /Peter

                Comment

                • Lionel B

                  #9
                  Re: error: function is taken as an micro

                  On Thu, 21 Aug 2008 16:37:58 +0000, Lionel B wrote:
                  On Thu, 21 Aug 2008 09:19:40 -0700, mohi wrote:
                  >
                  >hello everyone,
                  >>
                  >i use a function called minor to find the minor of an element of a
                  >matrix, i declare it as :
                  >>
                  >float minor(float A[ ][COL],int m,int n,int i,int j);//find the minor
                  >in A[][]
                  >
                  [...]
                  >as it seems the compiler is taking function minor() as macro ..... but
                  >why???
                  >
                  Maybe there really *is* a macro called `minor' defined somewhere?
                  FWIW, you're not the first to be caught out. A quick Google turned up
                  these, amongst others:




                  So its seems (some versions of?) sys/sysmacros.h (part of the GNU C
                  library on BSD/Linux) define a macro minor. On my system (Gentoo Linux
                  x86_64) sys/sysmacros.h contains:

                  /* Access the functions with their traditional names. */
                  # define major(dev) gnu_dev_major (dev)
                  # define minor(dev) gnu_dev_minor (dev)
                  # define makedev(maj, min) gnu_dev_makedev (maj, min)
                  #endif

                  Traditional names... hmmm, sounds like a historical thing, then. You'd
                  have thought at least uppercase names would have been better (and they
                  perhaps should be undef'ed appropriately in standard headers).

                  --
                  Lionel B

                  Comment

                  • Rolf Magnus

                    #10
                    Re: error: function is taken as an micro

                    Lionel B wrote:
                    FWIW, you're not the first to be caught out. A quick Google turned up
                    these, amongst others:
                    >


                    >
                    So its seems (some versions of?) sys/sysmacros.h (part of the GNU C
                    library on BSD/Linux) define a macro minor. On my system (Gentoo Linux
                    x86_64) sys/sysmacros.h contains:
                    >
                    /* Access the functions with their traditional names. */
                    # define major(dev) gnu_dev_major (dev)
                    # define minor(dev) gnu_dev_minor (dev)
                    # define makedev(maj, min) gnu_dev_makedev (maj, min)
                    #endif
                    >
                    Traditional names... hmmm, sounds like a historical thing, then. You'd
                    have thought at least uppercase names would have been better (and they
                    perhaps should be undef'ed appropriately in standard headers).
                    They are - if you use the compiler in standard mode. (-ansi or -std=c++98).

                    Comment

                    • Jack Klein

                      #11
                      Re: error: function is taken as an micro

                      On Thu, 21 Aug 2008 09:33:02 -0700 (PDT), mlimber <mlimber@gmail. com>
                      wrote in comp.lang.c++:
                      On Aug 21, 12:19 pm, mohi <mohangupt...@g mail.comwrote:
                      as it seems the compiler is taking function minor() as macro .....
                      but why???
                      and how is the function declaration invalid??
                      >
                      That's not a standard macro; it's something specific to your code,
                      your system, or third-party libraries. You can #undef it in your
                      header:
                      >
                      #ifdef minor
                      # undef minor
                      #endif
                      The #ifdef / #endif are completely unnecessary. It is perfectly legal
                      and a preprocessor no-op to #undef a symbol unknown to the
                      preprocessor.

                      --
                      Jack Klein
                      Home: http://JK-Technology.Com
                      FAQs for
                      comp.lang.c http://c-faq.com/
                      comp.lang.c++ http://www.parashift.com/c++-faq-lite/
                      alt.comp.lang.l earn.c-c++

                      Comment

                      • Jack Klein

                        #12
                        Re: error: function is taken as an micro

                        On Thu, 21 Aug 2008 16:37:58 GMT, Lionel B <me@privacy.net wrote in
                        comp.lang.c++:
                        On Thu, 21 Aug 2008 09:19:40 -0700, mohi wrote:
                        >
                        hello everyone,

                        i use a function called minor to find the minor of an element of a
                        matrix ,
                        i declare it as :

                        float minor(float A[ ][COL],int m,int n,int i,int j);//find the minor in
                        A[][]
                        >
                        [...]
                        >
                        when i compile it using gnu g++ it gives the following error :


                        solve_equation. cpp:13:51: error: macro "minor" passed 5 arguments, but
                        takes just 1
                        solve_equation. cpp:68:49: error: macro "minor" passed 5 arguments, but
                        takes just 1
                        solve_equation. cpp:76:51: error: macro "minor" passed 5 arguments, but
                        takes just 1
                        solve_equation. cpp:121:51: error: macro "minor" passed 5 arguments, but
                        takes just 1
                        solve_equation. cpp:76: error: invalid function declaration


                        as it seems the compiler is taking function minor() as macro ..... but
                        why???
                        >
                        Maybe there really *is* a macro called `minor' defined somewhere? Try
                        giving your function a different name and see if it compiles. Or insert
                        some code like:
                        >
                        #ifdef minor
                        #error macro minor already defined!
                        #endif
                        The #ifdef / #endif are completely unnecessary. It is perfectly legal
                        and a preprocessor no-op to #undef a symbol unknown to the
                        preprocessor.

                        --
                        Jack Klein
                        Home: http://JK-Technology.Com
                        FAQs for
                        comp.lang.c http://c-faq.com/
                        comp.lang.c++ http://www.parashift.com/c++-faq-lite/
                        alt.comp.lang.l earn.c-c++

                        Comment

                        • tony_in_da_uk@yahoo.co.uk

                          #13
                          Re: error: function is taken as an micro

                          On Aug 22, 1:52 am, mohi <mohangupt...@g mail.comwrote:
                          so where could [macro minor] have been declared ????can it be in cmath????
                          Your question's already been answered - at least if your Linux
                          platform does something similar. The general technique though is to
                          ask your preprocessor or compiler to list the macros in affect - check
                          the command line switches.

                          Tony

                          Comment

                          • mlimber

                            #14
                            Re: error: function is taken as an micro

                            On Aug 21, 11:43 pm, Jack Klein <jackkl...@spam cop.netwrote:
                            On Thu, 21 Aug 2008 09:33:02 -0700 (PDT), mlimber <mlim...@gmail. com>
                            wrote in comp.lang.c++:
                            >
                            On Aug 21, 12:19 pm, mohi <mohangupt...@g mail.comwrote:
                            as it seems the compiler is taking function minor() as macro .....
                            but why???
                            and how is the function declaration invalid??
                            >
                            That's not a standard macro; it's something specific to your code,
                            your system, or third-party libraries. You can #undef it in your
                            header:
                            >
                             #ifdef minor
                             #  undef minor
                             #endif
                            >
                            The #ifdef / #endif are completely unnecessary.  It is perfectly legal
                            and a preprocessor no-op to #undef a symbol unknown to the
                            preprocessor.
                            Right you are. I originally had some preprocessing code to restore the
                            macro if desired, but then I deleted it and should have deleted the
                            ifdef, too.

                            Cheers! --M

                            Comment

                            Working...