Includes in portable.h

ulmus71 wrote on Thursday, September 08, 2011:

Can anyone cen help me and tell where ‘MPLAB_PIC32MX_PORT’ is defined?
I have searched everything i think, but couldnt find how is ‘portmacro.h’ included???

rtel wrote on Thursday, September 08, 2011:

Older demos used the mechanism of defining a port specific constant, such as MPLAB_PIC32MX_PORT, to allow portable.h to then include the correct portmacro.h file.  When this scheme is used, the definition is part of the project file.  In the case of MPLAB, to find or create the definition, you would have to use the MPLAB IDE menus to bring up the project options, then go to the preprocessor definitions section, and just add MPLAB_PIC32MX_PORT as a definition.

However, newer demo projects no longer use this mechanism, as it become unwieldy with so many ports.  Portable.h has changed in recent versions to include the following lines after all the conditional includes of portmacro.h:

/* Catch all to ensure portmacro.h is included in the build.  Newer demos
have the path as part of the project options, rather than as relative from
the project location.  If portENTER_CRITICAL() has not been defined then
portmacro.h has not yet been included - as every portmacro.h provides a
portENTER_CRITICAL() definition.  Check the demo application for your demo
to find the path to the correct portmacro.h file. */
#ifndef portENTER_CRITICAL
	#include "portmacro.h"	

That means that, to include the correct portmacro.h header file, you simply add the path to the header file to the existing include path list.


ulmus71 wrote on Thursday, September 08, 2011:

Oh, so many many thanx to you!!!
I haven’t noticed those lines :frowning: