This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Strange function declared implicitly warning

Other Parts Discussed in Thread: CC2520

I want to preface this by saying that my code runs as expected. 

I took a large MSP430 source code file and broke it up into separate header and source files to reduce the main source block.  All of the headers are included correctly but for some reason I still get a function declared implicitly warning.  Is there a reason why this would happen?  My h files are included at the top of my main block.  Does the compiler look at the original source before it checks the includes?  Any insight into the problem is appreciated since I don't want this to bite me in the butt further down the line.

Cheers,

-Eric

  • For me, I usually accidentally cut'n'paste the same "#ifndef THIS_FILE, #define THIS_FILE" part in more than one header file. The first header file will define THIS_FILE and get included. The second header will see the THIS_FILE and not get included. Without source code it's tough to tell.

  • You probably have a function (the warning tells you which one) for which you didn't create a prototype in the header file.  When everything is one source file and the function is declared before it is used, you won't get the warning, which would explain why you do get the warning with your current refactoring but you didn't when it was one source file.

    Are you using C++?  If you make a small mistake in the prototype, it defines a different function.  Double-check the types of the parameters.

  • The prototypes are defined in the header... Here is an example:

    main source code calls:

    init_INTclock();

    header file contains declaration

    void init_INTclock(void);

    secondary source file that links to header has:

    // Initialize the clock to be the internal oscillator

    void init_INTclock(void)

    {

     

      // ------------------------------------------------

      // Clock setup

      // ------------------------------------------------

      // Try using CAL commands to get 8MHz clock

      // MCLK: source is DCOCLK, f = 8 MHz

      // SMCLK: source is DCOCLK, do not divide!

      // Although dividing MCLK will give better power efficiency, it will result in

      // interrmittent availablility of communication modules

      DCOCTL = CALDCO_8MHZ;

      BCSCTL1 = CALBC1_8MHZ;

      BCSCTL1 |= XT2OFF;

      BCSCTL2 = 0x00; // Set MCLK and SMCLK to DCOCLK

      BCSCTL3 |= LFXT1S_2;   // LFXT1 = VLO = ACLK = 12KHz

     

      // After turning on the crystal, we have to wait for it to stablize

      IFG1 &= ~OFIFG; // clear OSCFault flag

     

      uint8_t i = 0;

      while (i < 255) // time for flag to set

          i++;

    }

    The main source file includes the header file at the top and the secondary source file also includes the header.

  • I cannot reproduce this problem.  What is the exact text of the error message?  What compiler options are you using?

    I will need to see a test case which demonstrates the problem.  Could you create a small test case that demonstrates the problem and attach the files here?

     

  • The official error is:

    Warning:

    function declared implicitly


    The main source file is:

    /* Eric Winokur
     * 1/28/2011 - 2/&&/2011
     * SpO2 Firmware
     *
     * This code leverages the original vital signs code Rev_B designed by David He
     * It removes all Accelerometer code and adds firmware code necessary for
     * SpO2 sampling and data analysis.  This includes LED driver code
     *
     */
     
    // Include statements - Most are necessary for wireless stack
    //#define I_WANT_TO_CHANGE_DEFAULT_ROM_DEVICE_ADDRESS_PSEUDO_CODE
    #include "bsp.h"
    #include "msp_init.h"     // Designed by Eric




    /* work loop semaphores */
    //static volatile uint8_t sSelfMeasureSem = 0;

    void main (void)
    {  
      //addr_t lAddr;
     
      // BSP Init initially sets the clocks and TimerA and defines other functions
      BSP_Init();

      WDTCTL = WDTPW + WDTHOLD;                 // Stop watchdog timer

      // Initialize SMCLK and MCLK to 8 MHZ after flash addresses have been stored
        init_INTclock();

      while (1); //This is necessary so the TimerA interrupt will hit in linkTo()?
    }

    The header file is:

    /*  --------------------------------------------------------
     * Eric Winokur
     * December 2011 - January 2012
     *
     * Header file to declare MSP430 initialization functions
     * for pulse oximeter / vital signs monitor
     * ---------------------------------------------------------*/
       
     // Include Statements
     #include "bsp.h"
     
     // Declare System Functions
    // Initializes SMCLK and MCLK to 8 MHZ DCO
    void init_INTclock(void);

    // initialize TimerA to trigger the ADC on interrupts
    void init_TimerA(void);
    // Initialize TimerB to wait 250us for DAC settling
    void init_TimerB(void);

    //SPI && I2C initialization
    void init_SPI_Radio(void);

    // Initializes relevant I/O
    void init_PORTS(void);

    The other source file is:

    /* -------------------------------------------
     * Eric Winokur
     * January 2012
     *
     * MSP430 initialization function definitions
     * -------------------------------------------*/

    // Include Files
    #include "msp_init.h"        // Header file linked to this C file
    #include "binary.h"                // Dave's Header File
    #include "bsp.h"

    // Initialize the clock to be the internal oscillator
    void init_INTclock(void)
    {
     
      // ------------------------------------------------
      // Clock setup
      // ------------------------------------------------
      // Try using CAL commands to get 8MHz clock
      // MCLK: source is DCOCLK, f = 8 MHz
      // SMCLK: source is DCOCLK, do not divide!
      // Although dividing MCLK will give better power efficiency, it will result in
      // interrmittent availablility of communication modules
      DCOCTL = CALDCO_8MHZ;
      BCSCTL1 = CALBC1_8MHZ;
      BCSCTL1 |= XT2OFF;
      BCSCTL2 = 0x00; // Set MCLK and SMCLK to DCOCLK
      BCSCTL3 |= LFXT1S_2;   // LFXT1 = VLO = ACLK = 12KHz
     
      // After turning on the crystal, we have to wait for it to stablize
      IFG1 &= ~OFIFG; // clear OSCFault flag
     
      uint8_t i = 0;
      while (i < 255) // time for flag to set
          i++;
    }

    // Initialize Timer_A for 500 Hz
    // This will be used for ADC triggering
    void init_TimerA(void)
    {
        /* Reset the timer */
      TACTL |= TACLR; /* Set the TACLR */

      /* Clear all settings */
      TACTL = 0x0;
     
        // Timer time: (2 bytes/Sample, 256000baud) - Timer Mode = UP
      // 1=1430 SPS, 10=445 SPS, 20=340 SPS, 40=230 SPS
      // Assuming 12K ACLK, TACCR0 = 24 for 500 Hz sampling
      TACCR0 = 24;                                   // 12K / 40 = 500 (250 for IR & Red)
      TACTL = TASSEL_1 + MC_1;                  // ACLK, upmode
      TACCTL0 = CCIE;                           // TACCR0 interrupt enabled
    }

    // Initialize Timer_B for 250 us
    // This will be used for DAC settling
    void init_TimerB(void)
    {
        /* Reset the timer */
      TBCTL |= TBCLR; /* Set the TACLR */

      /* Clear all settings */
      TBCTL = 0x0;
     
      // Assuming 12K ACLK, TACCR0 = 3 for 250 us
      TBCCR0 = 4;                        // 12K / 3 = 250 us (250 for IR & Red)
      TBCTL = TBSSEL_1;                  // ACLK is the source
      TBCCTL0 = CCIE;                    // TBCCR0 interrupt enabled
    }

    // Initialize USCI_B0 for SPI to interface with the Radio
    void init_SPI_Radio(void)
    {
        // Turn off all chip selects
        //P2OUT |= BIT4;                // Turn off DAC but do not change LED switch
        P4OUT |= BIT4;                // Turn off ADC
      P3OUT |= BIT0;                 // turn off radio SPI
      P3SEL = b00001110;        // SPI mode
     
      UCB0CTL1 |= UCSWRST; // set SPI to ADC's SPI protocol
      UCB0BR0 = b00000010; // set SPI clock to 4MHz
      UCB0BR1 = b00000000;
     
      // Data captured on first edge; Inactive Low; MSB first; 8-bit data; Master;
      // 3-Pin SPI; Synchronous
        UCB0CTL0 = b10101001;    
        UCB0CTL1 &= ~UCSWRST;
        
        P3OUT &= ~BIT0;                // Turn on radio    
    }

    // Initialize all necessary pins for inp / out/ sel
    void init_PORTS(void)
    {
        P2DIR = b00011111;    // 2.4=DAC_EN, 2.2=LED_2, 2.0=LED_1, DAC_EN HIGH = OFF
        P2OUT = 0x10;                // 2.1 & 2.3 are for debugging,
        
        P3SEL = b00001110;    // SPI = P3.1 - P3.3
        P3DIR = 0x01;                // P3.0 = RADIO CS
        P3OUT = 0x01;                // CS HIGH TURNS OFF RADIO
        
        P4DIR = b01111000;    // P4.4 = ADC_CS, 4.3 & 4.5 & 4.6 are for debugging
        P4OUT = 0x10;                // CS HIGH TURNS OFF ADC
    }

    bsp.h is:

    /**************************************************************************************************
      Revised:        $Date: 2007-07-06 11:19:00 -0700 (Fri, 06 Jul 2007) $
      Revision:       $Revision: 13579 $

      Copyright 2007 Texas Instruments Incorporated.  All rights reserved.

      IMPORTANT: Your use of this Software is limited to those specific rights granted under
      the terms of a software license agreement between the user who downloaded the software,
      his/her employer (which must be your employer) and Texas Instruments Incorporated (the
      "License"). You may not use this Software unless you agree to abide by the terms of the
      License. The License limits your use, and you acknowledge, that the Software may not be
      modified, copied or distributed unless embedded on a Texas Instruments microcontroller
      or used solely and exclusively in conjunction with a Texas Instruments radio frequency
      transceiver, which is integrated into your product. Other than for the foregoing purpose,
      you may not use, reproduce, copy, prepare derivative works of, modify, distribute,
      perform, display or sell this Software and/or its documentation for any purpose.

      YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE PROVIDED “AS IS”
      WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY
      WARRANTY OF MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
      IN NO EVENT SHALL TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
      NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER LEGAL EQUITABLE
      THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES INCLUDING BUT NOT LIMITED TO ANY
      INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST
      DATA, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY
      THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.

      Should you have any questions regarding your right to use this Software,
      contact Texas Instruments Incorporated at www.TI.com.
    **************************************************************************************************/

    /* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     *   BSP (Board Support Package)
     *   Include file for core BSP services.
     * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     */

    #ifndef BSP_H
    #define BSP_H


    /* ------------------------------------------------------------------------------------------------
     *                                           Includes
     * ------------------------------------------------------------------------------------------------
     */
    #include "bsp_board_defs.h"
    #include "bsp_macros.h"

    /* ------------------------------------------------------------------------------------------------
     *                                          BSP Defines
     * ------------------------------------------------------------------------------------------------
     */
    #define BSP
    #define BSP_VER       100  /* BSP version 1.00a */
    #define BSP_SUBVER    a


    /* ------------------------------------------------------------------------------------------------
     *                                            Clock
     * ------------------------------------------------------------------------------------------------
     */
    #define BSP_CLOCK_MHZ   __bsp_CLOCK_MHZ__


    /* ------------------------------------------------------------------------------------------------
     *                                            Memory
     * ------------------------------------------------------------------------------------------------
     */
    #ifndef __bsp_LITTLE_ENDIAN__
    #error ERROR: Endianess not defined
    #endif

    #define BSP_LITTLE_ENDIAN   __bsp_LITTLE_ENDIAN__

    #define CODE    __bsp_CODE_MEMSPACE__
    #define XDATA   __bsp_XDATA_MEMSPACE__

    /* ------------------------------------------------------------------------------------------------
     *                                            Interrupts
     * ------------------------------------------------------------------------------------------------
     */
    #define BSP_ISR_FUNCTION(func,vect)     __bsp_ISR_FUNCTION__(func,vect)

    #define BSP_ENABLE_INTERRUPTS()         __bsp_ENABLE_INTERRUPTS__()
    #define BSP_DISABLE_INTERRUPTS()        __bsp_DISABLE_INTERRUPTS__()
    #define BSP_INTERRUPTS_ARE_ENABLED()    __bsp_INTERRUPTS_ARE_ENABLED__()


    /* ------------------------------------------------------------------------------------------------
     *                                         Critical Sections
     * ------------------------------------------------------------------------------------------------
     */
    typedef __bsp_ISTATE_T__  bspIState_t;

    #define BSP_ENTER_CRITICAL_SECTION(x)   st( x = __bsp_GET_ISTATE__(); __bsp_DISABLE_INTERRUPTS__(); )
    #define BSP_EXIT_CRITICAL_SECTION(x)    __bsp_RESTORE_ISTATE__(x)
    #define BSP_CRITICAL_STATEMENT(x)       st( bspIState_t s;                    \
                                                BSP_ENTER_CRITICAL_SECTION(s);    \
                                                x;                                \
                                                BSP_EXIT_CRITICAL_SECTION(s); )


    /* ------------------------------------------------------------------------------------------------
     *                                           Asserts
     * ------------------------------------------------------------------------------------------------
     */

    /*
     *  BSP_ASSERT( expression ) - The given expression must evaluate as "true" or else the assert
     *  handler is called.  From here, the call stack feature of the debugger can pinpoint where
     * the problem occurred.
     *
     *  BSP_FORCE_ASSERT() - If asserts are in use, immediately calls the assert handler.
     *
     *  BSP_ASSERTS_ARE_ON - can use #ifdef to see if asserts are enabled
     *
     *  Asserts can be disabled for optimum performance and minimum code size (ideal for
     *  finalized, debugged production code).
     */

    #if (!defined BSP_NO_DEBUG)
    #ifndef BSP_ASSERT_HANDLER
    #define BSP_ASSERT_HANDLER()      st( __bsp_DISABLE_INTERRUPTS__();  while(1); )
    #endif
    #define BSP_ASSERT(expr)          st( if (!(expr)) BSP_ASSERT_HANDLER(); )
    #define BSP_FORCE_ASSERT()        BSP_ASSERT_HANDLER()
    #define BSP_ASSERTS_ARE_ON
    #else
    #define BSP_ASSERT(expr)          /* empty */
    #define BSP_FORCE_ASSERT()        /* empty */
    #endif

    /* static assert */
    #define BSP_STATIC_ASSERT(expr)   void bspDummyPrototype( char dummy[1/((expr)!=0)] )


    /* ------------------------------------------------------------------------------------------------
     *                                           Prototypes
     * ------------------------------------------------------------------------------------------------
     */
    void BSP_Init(void);
    /**************************************************************************************************
     */

    /****************************************************************************************
     *                                 BEGIN ENDIAN SUPPORT
     *
     * Security encrypt/decrypt operates on unsigned long quantities. These must match on
     * source and destination platforms. These macros enforce the standard conversions.
     * Currently all platforms (CC2520/CC2x30 and MSP430) are little endian.
     *
     *******************   Network order for encryption is LITTLE ENDIAN   ******************
     *
     ****************************************************************************************/

    #if (BSP_LITTLE_ENDIAN != 0)
    #define   ntohs(x)    (x)
    #define   htons(x)    (x)

    #define   ntohl(x)    (x)
    #define   htonl(x)    (x)

    #else

    #define   ntohs(x)    (((x>>8) & 0xFF) | ((x & 0xFF)<<8))
    #define   htons(x)    (((x>>8) & 0xFF) | ((x & 0xFF)<<8))

    #define   ntohl(x)    ( ((x>>24) & 0xFF) | ((x>>8) & 0xFF00) | \
                            ((x & 0xFF00)<<8) | ((x & 0xFF)<<24)   \
                          )
    #define   htonl(x)    ( ((x>>24) & 0xFF) | ((x>>8) & 0xFF00) | \
                            ((x & 0xFF00)<<8) | ((x & 0xFF)<<24)   \
                          )

    #endif  /* (BSP_LITTLE_ENDIAN != 0) */

    /***************************************************************************************
     *                                 END ENDIAN SUPPORT
     ***************************************************************************************/



    #endif

    and bsp.c is:

    /**************************************************************************************************
      Revised:        $Date: 2007-07-06 11:19:00 -0700 (Fri, 06 Jul 2007) $
      Revision:       $Revision: 13579 $

      Copyright 2007 Texas Instruments Incorporated.  All rights reserved.

      IMPORTANT: Your use of this Software is limited to those specific rights granted under
      the terms of a software license agreement between the user who downloaded the software,
      his/her employer (which must be your employer) and Texas Instruments Incorporated (the
      "License"). You may not use this Software unless you agree to abide by the terms of the
      License. The License limits your use, and you acknowledge, that the Software may not be
      modified, copied or distributed unless embedded on a Texas Instruments microcontroller
      or used solely and exclusively in conjunction with a Texas Instruments radio frequency
      transceiver, which is integrated into your product. Other than for the foregoing purpose,
      you may not use, reproduce, copy, prepare derivative works of, modify, distribute,
      perform, display or sell this Software and/or its documentation for any purpose.

      YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE PROVIDED “AS IS”
      WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY
      WARRANTY OF MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
      IN NO EVENT SHALL TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
      NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER LEGAL EQUITABLE
      THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES INCLUDING BUT NOT LIMITED TO ANY
      INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST
      DATA, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY
      THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.

      Should you have any questions regarding your right to use this Software,
      contact Texas Instruments Incorporated at www.TI.com.
    **************************************************************************************************/

    /* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     *   BSP (Board Support Package)
     *   Top-level BSP code file.
     * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     */

    /* ------------------------------------------------------------------------------------------------
     *                                            Includes
     * ------------------------------------------------------------------------------------------------
     */
    #include "bsp.h"
    #include "bsp_driver_defs.h"


    /**************************************************************************************************
     * @fn          BSP_Init
     *
     * @brief       Initialize the board and drivers.
     *
     * @param       none
     *
     * @return      none
     **************************************************************************************************
     */
    void BSP_Init(void)
    {
      BSP_INIT_BOARD();
      BSP_INIT_DRIVERS();

      /*-------------------------------------------------------------
       *  Run time integrity checks.  Perform only if asserts
       *  are enabled.
       */
    #ifdef BSP_ASSERTS_ARE_ON
      /* verify endianess is correctly specified */
      {
        uint16_t test = 0x00AA; /* first storage byte of 'test' is non-zero for little endian */
        BSP_ASSERT(!(*((uint8_t *)&test)) == !BSP_LITTLE_ENDIAN); /* endianess mismatch */
      }
    #endif
    }


    /* ================================================================================================
     *                                        C Code Includes
     * ================================================================================================
     */
    #ifdef BSP_BOARD_C
    #include BSP_BOARD_C
    #endif

    #ifdef BSP_DRIVERS_C
    #include BSP_DRIVERS_C
    #endif


    /* ************************************************************************************************
     *                                   Compile Time Integrity Checks
     * ************************************************************************************************
     */
    BSP_STATIC_ASSERT( sizeof(  uint8_t ) == 1 );
    BSP_STATIC_ASSERT( sizeof(   int8_t ) == 1 );
    BSP_STATIC_ASSERT( sizeof( uint16_t ) == 2 );
    BSP_STATIC_ASSERT( sizeof(  int16_t ) == 2 );
    BSP_STATIC_ASSERT( sizeof( uint32_t ) == 4 );
    BSP_STATIC_ASSERT( sizeof(  int32_t ) == 4 );


    /**************************************************************************************************
     */








  • I still can't reproduce the warning.  The full text of the warning should include file and line number, like this:

    "main.c", line 27: warning: function declared implicitly

    Which file, and which line number do the warning occur on?

  • Maybe I'm using a different version of code composser?  The warning only says what I wrote previously and then there is an exclamation point on line 32 of main_ED.c (The line that has init_INTclock()

  • I'm not using Code Composer at all. I'm using the compiler directly. Code Composer takes the compiler's warning and fancies it up a bit, but you should still be able to see the output of the compiler in the "Console" window.

    This behavior should be the same in any version of the compiler you would be using. What version of Code Composer are you using? What version of the compiler?

  • So this is wierd... yesterday when I compiled I got the warning.  Today when I compile it is gone.  Maybe CCS needed a restart???

  • Hmmm so I think I've narrowed down the problem.  When I add other include statements but do not change any other portion of the code, I get the function declared implicitly error.  I think it might be the order of my included header files.

  • Okay so I got the full code to compile without errors.  It seems that the first time that I compile I get the implicit function warnings for every function called from a user generated h file.  However, if I then recompile without changing any of the code, the warnings disapear.  I think that the code is correct and that the compiler might need a second pass to make sure that everything has been properly declared?  Anyways, I don't think the problem is worth spending any more time on at this point.  Thanks for your help.

    -E

  • Okay so I got the full code to compile without errors.  It seems that the first time that I compile I get the implicit function warnings for every function called from a user generated h file.  However, if I then recompile without changing any of the code, the warnings dissapear.  I think that the code is correct and that the compiler might need a second pass to make sure that everything has been properly declared?  Anyways, I don't think the problem is worth spending any more time on at this point.  Thanks for your help.

    -E

  • Are you sure the files are really being recompiled the second time around?  Perhaps Code Composer realizes that it doesn't need to recompile the files because you haven't changed them?

  • I guess I'm not sure.  Although I don't know why errors and warnings would dissapear when hitting the build and compile button twice.

  • Errors would not disappear when doing a second build.

    On the other hand for warnings, a first build would give warnings but still successfully compile the file.  A second build would see that the object file (created by the first build) is newer than the source and not re-compile the unchanged file.  Thus no warnings on a second build.

     

  • I figured out the problem.  Code Composer was saving the header files that I was working on in one directory, but looking for them in another directory!