cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F030R8-Nucleo I2C_TwoBoards_ComPolling example - COUNTOF macro

Franksterb92
Senior

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

 

1 REPLY 1
Andrew Neil
Super User

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.