expected identifier before numeric constant

This is a discussion on expected identifier before numeric constant within the C Programming forums, part of the General Programming Boards category; I'm getting those errors for the following piece of code Code: #if (CONFIG_OSC_RC32_CAL==48000000UL) MSB(cal) = nvm_read_production_signature_row( nvm_get_production_signature_row_offset(USBRCOSC)); LSB(cal) = nvm_read_production_signature_row( ...

  1. #1
    Registered User
    Join Date
    May 2012
    Location
    Netherlands
    Posts
    24

    expected identifier before numeric constant

    I'm getting those errors for the following piece of code

    Code:
    #if (CONFIG_OSC_RC32_CAL==48000000UL)            MSB(cal) = nvm_read_production_signature_row(
                        nvm_get_production_signature_row_offset(USBRCOSC));
                LSB(cal) = nvm_read_production_signature_row(
                        nvm_get_production_signature_row_offset(USBRCOSCA));
    The errors are at nvm_get_production_signature_row_offset.

    The definition of the variable is here:
    Code:
    #if defined(__GNUC__)
    # define nvm_get_production_signature_row_offset(regname) \
            offsetof(NVM_PROD_SIGNATURES_t, regname)
    #elif defined(__ICCAVR__)
    # define nvm_get_production_signature_row_offset(regname) (regname##_offset)
    #else
    #  error Unknown compiler
    #endif
    I think I'm seeing over some minor things but I can't find an answer.

    Have used the search here on the forum but found out nothing.

    I've got the code from ftp://efo-6.ip.peterstar.net/pub/efo...58977675762dd3 but I can't find an explanation there to solve the problem

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    2,768
    And, the compiler you are using is what??

    Tim S.
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the Universe is winning." Rick Cook

  3. #3
    Registered User
    Join Date
    May 2012
    Location
    Netherlands
    Posts
    24
    AVR studio 5

    Even if I put

    Code:
    #ifndef __GNUC__
    #define __GNUC__
    #endif
    I still get the same errors

  4. #4
    Registered User
    Join Date
    May 2009
    Posts
    2,768
    Quote Originally Posted by Elixz View Post
    AVR studio 5
    FYI: That is the name of an IDE; NOT the name of a Compiler.

    Are you using GNU C or ICC AVR?
    If not, the code you posted will NOT work!!

    Tim S.
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the Universe is winning." Rick Cook

  5. #5
    Registered User
    Join Date
    May 2012
    Location
    Netherlands
    Posts
    24
    I'm using GNUC, sorry for the miss understanding

  6. #6
    Registered User
    Join Date
    May 2009
    Posts
    2,768
    I would verify the code is for your chip.
    After you verify that I would post on a web-site that supports the chip manufacturer and your C Compiler.

    The other option is using GCC to get the preprocessed output (normally option -E) and seeing if that help determine what is missing.
    Likely missing an include or using code from wrong micro-controller chip.

    Tim S.
    Last edited by stahta01; 05-30-2012 at 07:15 AM.
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the Universe is winning." Rick Cook

  7. #7
    Registered User
    Join Date
    May 2012
    Location
    Netherlands
    Posts
    24
    I am using this software for the ATXMega16A4U and the software is designed for the same microcontroller.

    USB Device CDC Example for XMEGA-A3BU Xplained: File List

    All the files you see here are added in the solution

  8. #8
    Registered User
    Join Date
    May 2012
    Location
    Netherlands
    Posts
    24
    F*** by posting the URL I saw the problem -.-

    Changing my mcu in avr studio to an atxmega..a3bu. I will let you know

  9. #9
    Registered User
    Join Date
    May 2012
    Location
    Netherlands
    Posts
    24
    Nope still the same problem. -.-

  10. #10
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,824
    > #if (CONFIG_OSC_RC32_CAL==48000000UL) MSB(cal) = nvm_read_production_signature_row(
    Is this REALLY all on one line?

    Because it seems to me it should be
    Code:
    #if (CONFIG_OSC_RC32_CAL==48000000UL)            
        MSB(cal) = nvm_read_production_signature_row(
    > The errors are at nvm_get_production_signature_row_offset.
    Yes, it has an extra ), if the previous long line has been munched by the pre-processor.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  11. #11
    Registered User
    Join Date
    May 2012
    Location
    Netherlands
    Posts
    24
    After the if statement the functions come, I mend it like this :

    Code:
    #if (CONFIG_OSC_RC32_CAL==48000000UL)
                MSB(cal) = nvm_read_production_signature_row(nvm_get_production_signature_row_offset(USBRCOSC));
    Same for the LSB(cal) = ...

  12. #12
    Registered User
    Join Date
    May 2009
    Posts
    2,768
    Since the same code is used here http://asf.atmel.com/docs/latest/xme...8c_source.html

    I would try the same headers to see if the cause is missing one of these headers.

    Tim S.
    PS: I still think you should see the preprocessed output to find the cause or seek help elsewhere.

    Code:
    #include <compiler.h>
    
    #include <sysclk.h>
    #include <osc.h>
    #include <pll.h>
     
    #if XMEGA_AU || XMEGA_B || XMEGA_C
    #  include <nvm.h>
    #endif
    Last edited by stahta01; 05-30-2012 at 09:07 AM.
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the Universe is winning." Rick Cook

  13. #13
    Registered User
    Join Date
    May 2009
    Posts
    2,768
    Did the example file work without you doing any modifications?

    ftp://ftp.efo.ru/pub/efo-ftp/TMP/pub...29_source.html

    Or, did the example project that ships with AVR Studio work without modification?

    Tim S.
    Last edited by stahta01; 05-30-2012 at 11:45 AM.
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the Universe is winning." Rick Cook

  14. #14
    Registered User
    Join Date
    May 2012
    Location
    Netherlands
    Posts
    24
    Quote Originally Posted by stahta01 View Post
    Since the same code is used here ASF Source Code Documentation - UC3 A0/A1: Main Page

    I would try the same headers to see if the cause is missing one of these headers.

    Tim S.
    PS: I still think you should see the preprocessed output to find the cause or seek help elsewhere.

    Code:
    #include <compiler.h>
    
    #include <sysclk.h>
    #include <osc.h>
    #include <pll.h>
     
    #if XMEGA_AU || XMEGA_B || XMEGA_C
    #  include <nvm.h>
    #endif
    I have tried to add the last if statement and the errors go away that I had before.
    I have also changed the brackets from the include files from <> to "" because with <> he won't recognize the .h file
    But now the compiler says that I need to add a ')' before the ; token in the same lines I had the errors therefore.

  15. #15
    Registered User
    Join Date
    May 2009
    Posts
    2,768
    Quote Originally Posted by stahta01 View Post
    Did the example file work without you doing any modifications?

    ftp://ftp.efo.ru/pub/efo-ftp/TMP/pub...29_source.html

    Or, did the example project that ships with AVR Studio work without modification?

    Tim S.
    I still see no answers to these questions.

    NOTE: The example project that ships with AVR Studio worked for me.
    So, I am thinking user error (either yours or mine) or bad AVR Studio installation.

    Tim S.
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the Universe is winning." Rick Cook

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. expected constant expression?
    By GroogFish in forum C Programming
    Replies: 3
    Last Post: 05-08-2012, 01:17 AM
  2. error: expected identifier or β(β before βwhileβ
    By philgrek in forum C Programming
    Replies: 9
    Last Post: 04-19-2011, 02:28 PM
  3. expected identifier
    By ozu in forum C Programming
    Replies: 5
    Last Post: 08-21-2010, 07:32 PM
  4. Error: expected identifier or ‘(’ before ‘{’ token
    By jpcanaverde in forum C Programming
    Replies: 66
    Last Post: 06-08-2010, 01:53 PM
  5. expected constant expression
    By Brian in forum C Programming
    Replies: 4
    Last Post: 12-03-2003, 03:30 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21