2018-05-29 6:25 AM
Good day everyone,
I'm trying to create a typedef for array in a header file. The size of this array should be defined by a macro from another header file. A quick snippet of my code is as follows:
HTPA.h
#ifndef HTPA_H_
#define HTPA_H_
#define HTPA_IMG_WIDTH 80 // The array size I want
#endif /* HTPA_H_ */
ads.h
#ifndef ADS_H_
#define ADS_H_
#include 'HTPA.h'
typedef uint16_t ADS_GradImg [
HTPA_IMG_WIDTH
]; // The array typedef I want#endif /* ADS_H_ */
When I try to compile this I get the error:
../Inc/ads.h:65:31: error: 'HTPA_IMG_WIDTH
' undeclared here (not in a function) I have searched the web, but can't find a similar problem. I have a hunch that it is because how the pre-processor/compiler works, but can't seem to find a solution around it.Can I make this work? Or will I have to use a workaround?
Thanks in advance!
#gcc #c #typedef #header #macro2018-05-29 8:38 AM
So is it HTPA_IMG_WIDTH or HTPA_IMG_HEIGHT?
JW
2018-05-30 4:39 AM
Both. Sorry, I seemed to have written the question wrong. I have both defined.