Skip to main content
Franksterb92
Senior
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

 

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

Andrew Neil
Andrew NeilBest answer
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.

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Franksterb92
Senior
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