Go Down

Topic: "class was not declared in this scope" I could swear it was. (Read 1 time) previous topic - next topic

WizenedEE


#include will grab any text file, some things that get included aren't valid c or c++ so putting it in a .c, .h, or .cpp would be misleading.


You mean if you were doing
Code: [Select]

char* str =
#include "stringsource"
;

stringsource:
Code: [Select]

"Hello this is a string"

How would you do that without quotation marks in the included file?

pYro_65

That wasn't my exactly my intention, by text file I meant a non binary file, however, I'll post an example from some code I wrote a while ago to help me do a platform independent low level IO system.

This is part of the AVR implementation, it dynamically loads a particular file based on the chipset, that file is used to create an array of pins for port mapping.

Code: [Select]
#if defined(__AVR_ATmega168__) ||defined(__AVR_ATmega168P__) ||defined(__AVR_ATmega328P__)
#define CHIPSET ATmega_168_168P_328P
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
#define CHIPSET ATmega_1280_2560
#elif defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)
#define CHIPSET ATmega_644_644P_1284P
#elif defined(__AVR_ATmega32U4__)
#ifdef CORE_TEENSY
#define CHIPSET ATmega_32U4_A
#else
#define CHIPSET ATmega_32U4_B
#endif
#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
#define CHIPSET AT90USB_646_1286
#endif
#define _PIN( port, bit )      {&DDR##port, &PIN##port, &PORT##port, bit},

const static pin_map_t pinMap[] = {
#include INCLUDE_FILE_3(HARDWARE_PREFIX,GENX_PLATFORM,MAKE_DIR(CHIPSET),.pins)
};
#undef CHIPSET
#undef _PIN


and this is the pins file for the 328

Code: [Select]
_PIN( D, 0 )
_PIN( D, 1 )
_PIN( D, 2 )
_PIN( D, 3 )
_PIN( D, 4 )
_PIN( D, 5 )
_PIN( D, 6 )
_PIN( D, 7 )

_PIN( B, 0 )
_PIN( B, 1 )
_PIN( B, 2 )
_PIN( B, 3 )
_PIN( B, 4 )
_PIN( B, 5 )

_PIN( C, 0 )
_PIN( C, 1 )
_PIN( C, 2 )
_PIN( C, 3 )
_PIN( C, 4 )
_PIN( C, 5 )


This list is laid out for the Uno pin layout, very easy to re-order for other designs.

Go Up