Skip to main content
Graduate II
September 2, 2025
Solved

STM32F030R8-Nucleo I2C_TwoBoards_ComPolling example - COUNTOF macro

  • September 2, 2025
  • 2 replies
  • 238 views

im looking in the main.h file for this example and wondering where __BUFFER__ is defined thats used in this line 

#define COUNTOF(__BUFFER__) (sizeof(__BUFFER__) / sizeof(*(__BUFFER__)))

 

thanks for the help

 

    This topic has been closed for replies.
    Best answer by Andrew Neil

    It's just the parameter of the COUNTOF() macro

     

    When you "call" the macro, you replace it with the name of  whatever actual buffer you want; eg,

    uint8_t my_buffer[123];
    size_t buffer_length;
    
    buffer_length = COUNTOF( my_buffer );

     

    This is just standard C syntax - nothing specific to STM32.

    2 replies

    Super User
    September 2, 2025

    It's just the parameter of the COUNTOF() macro

     

    When you "call" the macro, you replace it with the name of  whatever actual buffer you want; eg,

    uint8_t my_buffer[123];
    size_t buffer_length;
    
    buffer_length = COUNTOF( my_buffer );

     

    This is just standard C syntax - nothing specific to STM32.

    Graduate II
    September 3, 2025

    oh ok that's kind of what i was thinking wen i used it in a different program and it didn't throw any errors