__AVR__ not defined in .hfile but definec in .cpp file??????

In the h file:

#ifdef __AVR__
		uint8_t m_nDataPinMask,				// Sowtware SPI data pin bitmask
				m_nClockPinMask;			// Sowtware SPI clock pin bitmask
		volatile uint8_t *m_pnDataPort,		// Sowtware SPI data PORT
						 *m_pnClockPort;	// Sowtware SPI clock PORT
#endif

In the cpp file:

// Software SPI write
void sw_spi_out(uint8_t nData) 
{
	for (uint8_t nI = 8; nI--; nI <<= 1)
	{
#ifdef __AVR__
		if(nData & 0x80) 
			*m_pnDataPort |=  m_nDataPinMask;
		else         
			*m_pnDataPort &= ~m_nDataPinMask;
		*m_pnClockPort |=  m_nClockPinMask;
		*m_pnClockPort &= ~m_nClockPinMask;
#else
		if (nData & 0x80)
			digitalWrite(m_nDataPin, HIGH);
		else
			digitalWrite(m_nDataPin, LOW);
		digitalWrite(m_nClockPin, HIGH);
		digitalWrite(m_nClockPin, LOW);
#endif
	}
}

Compile error:

C:\Program Files\Arduino\libraries\LEDStripAPA102\LEDStripAPA102.cpp: In function 'void sw_spi_out(uint8_t)':
C:\Program Files\Arduino\libraries\LEDStripAPA102\LEDStripAPA102.cpp:187: error: 'm_pnDataPort' was not declared in this scope
C:\Program Files\Arduino\libraries\LEDStripAPA102\LEDStripAPA102.cpp:187: error: 'm_nDataPinMask' was not declared in this scope
C:\Program Files\Arduino\libraries\LEDStripAPA102\LEDStripAPA102.cpp:189: error: 'm_pnDataPort' was not declared in this scope
C:\Program Files\Arduino\libraries\LEDStripAPA102\LEDStripAPA102.cpp:189: error: 'm_nDataPinMask' was not declared in this scope
C:\Program Files\Arduino\libraries\LEDStripAPA102\LEDStripAPA102.cpp:190: error: 'm_pnClockPort' was not declared in this scope
C:\Program Files\Arduino\libraries\LEDStripAPA102\LEDStripAPA102.cpp:190: error: 'm_nClockPinMask' was not declared in this scope

That can only mean that AVR is defined in the cpp file but not in the h file

I don't unserstand how this can be.

LEDStripAPA102.h (3.92 KB)

LEDStripAPA102.cpp (11.3 KB)

They are class variables. You omitted the class name here:

void sw_spi_out(uint8_t nData)

If you put it in, it compiles:

void CAPA102::sw_spi_out(uint8_t nData)

That can only mean that AVR is defined in the cpp file but not in the h file

You have to look deeper than jumping to assumptions like that. I commented out the #ifdef lines and it still happened, which disproves that theory.

I just downloaded the library and assumed it would compile. :confused:

Can't be bothered with that library - I am going to write my own the way I want it.