Skip to main content
Franksterb92
Senior
Sep 2, 2025 9:24 AM UTC
Solved

STM32F030R8-Nucleo I2C_TwoBoards_ComPolling example - COUNTOF macro

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.
Andrew Neil
Andrew NeilBest answer
Super User
Sep 2, 2025 9:33 AM UTC

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.

2 replies

Andrew Neil
Andrew NeilBest answer
Super User
Sep 2, 2025 9:33 AM UTC

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
Sep 3, 2025 9:37 PM UTC

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