• AVR Freaks

Hot!Error: too many positional arguments

Author
MAELIA
Starting Member
  • Total Posts : 56
  • Reward points : 0
  • Joined: 2009/05/04 00:52:38
  • Location: 0
  • Status: offline
2019/06/20 07:50:19 (permalink)
0

Error: too many positional arguments

Hello
I use MPLAB X V5.15
Compiler  XC16 (V1.36)
microcontrolleur dsPIC 30F4013
 
I would like to do some macro witch modify a bit in a variable
For exemple i have define a bit :
        #define  FlagX          Drapeau,#1      ;Drapeau is a variable
   
     My very simple macro !!!
 
         .macro Change FlagToSet
            bset \Flag
         .endm
 
     but we canno't use this macro
      
          Change FlagX
 
 
How can I do this ?
 
Thanks very much for all ideas
 
 
 
#1

15 Replies Related Threads

    1and0
    Access is Denied
    • Total Posts : 9287
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Error: too many positional arguments 2019/06/20 08:05:12 (permalink)
    +1 (1)
    MAELIA
         My very simple macro !!!
     
             .macro Change FlagToSet
                bset \Flag
             .endm

    Replace that with
    .macro Change Flag,Bit
      bset \Flag,\Bit
    .endm

    #2
    MAELIA
    Starting Member
    • Total Posts : 56
    • Reward points : 0
    • Joined: 2009/05/04 00:52:38
    • Location: 0
    • Status: offline
    Re: Error: too many positional arguments 2019/06/20 10:08:01 (permalink)
    0
    Thanks for our answer....
     
    but  the bit is already define  with       "#define  FlagX          Drapeau,#1 "
    and I wish to  reuse it
     
    thanks very much
    #3
    1and0
    Access is Denied
    • Total Posts : 9287
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Error: too many positional arguments 2019/06/20 10:33:02 (permalink)
    +2 (2)
    MAELIA 
    but  the bit is already define  with       "#define  FlagX          Drapeau,#1 "
    and I wish to  reuse it

    So use it as you have in your Post #1.  Have you even tried it yet?
     
     
    #4
    andersm
    Super Member
    • Total Posts : 2605
    • Reward points : 0
    • Joined: 2012/10/07 14:57:44
    • Location: 0
    • Status: offline
    Re: Error: too many positional arguments 2019/06/20 10:46:45 (permalink)
    +1 (1)
    When the C preprocessor macro is expanded, that becomes two arguments to the assembly macro, but it only accepts one. That is what 1and0 is trying to explain.
    #5
    MAELIA
    Starting Member
    • Total Posts : 56
    • Reward points : 0
    • Joined: 2009/05/04 00:52:38
    • Location: 0
    • Status: offline
    Re: Error: too many positional arguments 2019/06/21 00:23:59 (permalink)
    0
    Thank for the answers.....
     
    Yes I tried to use this macro and the result after compilation is "Error: too many positional arguments"
    My macro is written  in assembler not in "C"
     
    Thus  in my macro            .macro Change FlagToSet
                                             bset \Flag
                                           .endm
     
     
    The call of it by :               Change FlagX      (  #define  FlagX          Drapeau,#1  )

                bset \Flag is not translate in     bset Drapeau,#1
    It seems that there is no posibility ?
     
    always thanks very much
    #6
    andersm
    Super Member
    • Total Posts : 2605
    • Reward points : 0
    • Joined: 2012/10/07 14:57:44
    • Location: 0
    • Status: offline
    Re: Error: too many positional arguments 2019/06/21 02:26:59 (permalink)
    +2 (2)
    The answer was already given: change your assembly macro to take two arguments. How is that so difficult to comprehend?
    #7
    1and0
    Access is Denied
    • Total Posts : 9287
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Error: too many positional arguments 2019/06/21 03:08:01 (permalink)
    +1 (1)
    andersm
    The answer was already given: change your assembly macro to take two arguments. How is that so difficult to comprehend?

    I guess some people's skulls are just too thick. :(
     
    #8
    1and0
    Access is Denied
    • Total Posts : 9287
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Error: too many positional arguments 2019/06/21 03:15:53 (permalink)
    +3 (3)
    MAELIA
    Yes I tried to use this macro and the result after compilation is "Error: too many positional arguments"
    My macro is written  in assembler not in "C"
     
    Thus  in my macro            .macro Change FlagToSet
                                            bset \Flag
                                          .endm

    First, FlagToSet and Flag are NOT the same symbol. Do you realize they have different numbers of characters? Second, that is ONLY ONE argument; repeating, that is one NOT two.
     

    The call of it by :               Change FlagX      (  #define  FlagX          Drapeau,#1  )

               bset \Flag is not translate in     bset Drapeau,#1

    The C preprocessor replaces FlagX with Drapeau,#1 which has TWO arguments... TWO!!!
     

    It seems that there is no posibility ?

    Is my Post #2 so difficult to comprehend?
    #9
    MAELIA
    Starting Member
    • Total Posts : 56
    • Reward points : 0
    • Joined: 2009/05/04 00:52:38
    • Location: 0
    • Status: offline
    Re: Error: too many positional arguments 2019/06/21 06:31:58 (permalink)
    -1 (1)
    Thanks very much ,
     
    yes I enderstand 1 argument is converted in 2 arguments.... but how to do ( in assembleur) ?
    Can you give me an example of macro witch can do what I want ?
    the constraint is that  the bit is already define by #define  FlagX  Drapeau,#1 
     
    Yes I have make a mistake .....it was
     
             .macro Change FlagToSet
                  bset \FlagToSet     ;!!!!!!!!!!!!!!! not \Flag
             .endm
     
    best regards
     
     
    #10
    ric
    Super Member
    • Total Posts : 22647
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Error: too many positional arguments 2019/06/21 06:47:49 (permalink)
    +2 (2)
    You are STILL not reading the answers correctly.
    You were shown EXACTLY how to do it back in post#2 !

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #11
    1and0
    Access is Denied
    • Total Posts : 9287
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Error: too many positional arguments 2019/06/21 07:39:18 (permalink)
    +2 (2)
    MAELIA
    yes I enderstand 1 argument is converted in 2 arguments.... but how to do ( in assembleur) ?
    Can you give me an example of macro witch can do what I want ?
    the constraint is that  the bit is already define by #define  FlagX  Drapeau,#1 

    I'm sorry. :(  I cannot dumb it down any more than what I've posted. :(
    #12
    MAELIA
    Starting Member
    • Total Posts : 56
    • Reward points : 0
    • Joined: 2009/05/04 00:52:38
    • Location: 0
    • Status: offline
    Re: Error: too many positional arguments 2019/06/24 04:38:08 (permalink)
    0
    Hello
    (MPLAB X V5.15  ,  XC16 (V1.36)  , dsPIC 30F4013)
     
    Perhaps I don't read correctly the answers( french) and  for example ,this answer written by "ric"
    "You are STILL not reading the answers correctly.
    You were shown EXACTLY how to do it back in post#2 !" ......
    It is not easy to rewrite all my program (60000 lines) in which a flag is define (#define  FlagX  Drapeau,#1)
     
    in fact the macro proposed
    ".macro Change Flag,Bit
      bset \Flag,\Bit
    .endm
    "
    I must define Two arguments , one for le variable "flag" and one for the bit number I can't use   "define  FlagX  Drapeau,#1"
     
    Sorry not to anderstand very well, I have done it otherwise
    Thanks very very much for all the answers !
    #13
    ric
    Super Member
    • Total Posts : 22647
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Error: too many positional arguments 2019/06/24 06:40:43 (permalink)
    +2 (2)
    MAELIA
    ...
    I must define Two arguments , one for le variable "flag" and one for the bit number I can't use   "define  FlagX  Drapeau,#1"
     

    Yes you can. Doing it the way you say IS defining two arguments, which is what we have been telling you for days.
    Just try it!
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #14
    MAELIA
    Starting Member
    • Total Posts : 56
    • Reward points : 0
    • Joined: 2009/05/04 00:52:38
    • Location: 0
    • Status: offline
    Re: Error: too many positional arguments 2019/06/24 07:05:16 (permalink)
    0
    I give up because I 'm not able to anderstand, I'm surely a donkey ! Many thanks for your answers even if I have not been able to solve this problem
    great thanks !!!!
    #15
    1and0
    Access is Denied
    • Total Posts : 9287
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Error: too many positional arguments 2019/06/24 11:43:08 (permalink)
    +2 (2)
    MAELIA
    I give up because I 'm not able to anderstand, I'm surely a donkey ! Many thanks for your answers even if I have not been able to solve this problem

    This thread has got to win some kind of awards!
     
    Maelia, just forget everything of what you think you understand for a moment, and DO EXACTLY AS WE HAVE BEEN TELLING YOU. To the compiler, this
    #define FlagX Drapeau,#1
    Change FlagX

    is the SAME thing as this
    Change Drapeau,#1

     
    So the correct macro to use is what I've posted in Post #2 days ago. Replace your macro with the one in Post #2 and IT WILL WORK. For goodness' sake, JUST TRY IT!
     
    If you still don't get it, I'm going to give you the Darwin Awards. ;)
     
    #16
    Jump to:
    © 2019 APG vNext Commercial Version 4.5