Manage Compatibility with Standard IDEs

Projects developed by embedXcode are highly compatible with the standard IDEs, like Arduino and alike.

However, unlike the standard IDEs, code with embedXcode is true C++.

Declare Prototypes on Main Sketch

The main consequence of true C++ is the need for declaring prototypes of the functions in the main sketch.

In the example provided below, the prototype for functionB() is required, as functionB() is called by functionA() but defined after.

// Prototypes
void functionA();
void functionB();

// Functions
void functionA() 
{
    Serial.println("functionA");
    functionB();
}

void functionB() 
{
    Serial.println("functionB");
}

Without prototyping functionB(), compilation would raise an error. The standard IDEs add the prototypes on the main sketch.

Prototypes aren’t required for libraries as they are already included in the header file.

Prototypes are fully compatible with the standard IDEs.

Include Core Library on Main Sketch

The same #include statement to the core library is required on each header file of each library, as it is recommended for the standard IDEs.

// Core library - IDE-based
#if defined(WIRING) // Wiring specific
#include "Wiring.h"
#elif defined(MAPLE_IDE) // Maple specific
#include "WProgram.h"
#elif defined(ROBOTIS) // Robotis specific
#include "libpandora_types.h"
#include "pandora.h"
#elif defined(MPIDE) // chipKIT specific
#include "WProgram.h"
#elif defined(DIGISPARK) // Digispark specific
#include "Arduino.h"
#elif defined(ENERGIA) // LaunchPad specific
#include "Energia.h"
#elif defined(LITTLEROBOTFRIENDS) // LittleRobotFriends specific
#include "LRF.h"
#elif defined(MICRODUINO) // Microduino specific
#include "Arduino.h"
#elif defined(TEENSYDUINO) // Teensy specific
#include "Arduino.h"
#elif defined(REDBEARLAB) // RedBearLab specific
#include "Arduino.h"
#elif defined(RFDUINO) // RFduino specific
#include "Arduino.h"
#elif defined(SPARK) || defined(PARTICLE) // Particle / Spark specific
#include "application.h"
#elif defined(ARDUINO) // Arduino 1.0 and 1.5 specific
#include "Arduino.h"
#else // error
#error Platform not defined
#endif // end IDE

The #include statement

For more information on library development,

Include all Used Libraries in Main Sketch

The standard IDEs require including all the libraries in the main sketch, even those not used by the main sketch but used in libraries, while embedXcode allows naming only the libraries which are directly called by the main sketch.

In order to ensure compatibility with the standard IDEs, including all the libraries in the main sketch is thus highly recommended, as the standard IDEs require it. It doesn’t affect embedXcode.

List all the Used Libraries in Main Makefile

The standard IDEs include an automatic procedure to list the libraries used by a project, while embedXcode requires a list of those libraries in the main Makefile.

Two variable are provided: the APP_LIBS_LIST variable list the application libraries and the USER_LIBS_LIST variable the user's libraries.

The embedXcode+ edition adds a third variable, the LOCAL_LIBS_LIST variable, to select the local libraries, if they are located inside sub-folders on the project folder.

Manage Local Libraries

This section requires embedXcode+.

embedXcode+ allows to select local libraries when they are placed into sub-folders.

Standard IDEs do not manage sub-folders for libraries. The content of the sub-folders should be moved to the main folder of the project.

For more information on using sub-folders for local libraries,

For more information on selecting local libraries,

Manage Pre-Compiled Libraries

This section requires embedXcode+.

embedXcode+ allows to include pre-compiled libraries with extension .a along with their header files and a .board file.

Standard IDEs do not manage pre-compiled libraries. The pre-compiled library should be unarchived by running the Unarchive target to obtain the source code files.

For more information on pre-compiled libraries,

Make Energia MT Project Compatible

embedXcode includes some exclusive features for the Energia MT framework.

The rtosSetup() function isn't supported by Energia MT yet.

To make the project compatible,

  • Create a new sketch rtosGlobals.ino.

  • Copy-paste the rtosSetup() function.

  • Add an empty rtosLoop() function.

void rtosLoop()
{
    ;
}

Delete the old rtosSetup() function.

Similarly, global variables and constants are defined on the main sketch in Energia, while embedXcode relies on the rtosGlobals.h header file.

If global variables and constants are defined,

  • Move the global variables and constants from the rtosGlobals.h header file into the main sketch. The main sketch has the same name as the project.

  • Delete the rtosGlobals.h file.

Finally, embedXcode uses the specific variable ENERGIA_MT, which is not available on the standard IDE.

If the specific variable ENERGIA_MT is used,

  • Add the pre-processing statement on the impacted header files.
#define ENERGIA_MT

Because an Energia MT project has ARDUINO and ENERGIA already defined, those variables need to be tested in a given order.

#if defined(ENERGIA_MT)
// Energia MT specific
#elif defined(ENERGIA)
// Energia specific
#elif defined(ARDUINO)
// Arduino specific
#endif

For more information about Energia MT,

Manage Code for Multiple Platforms and MCUs

embedXcode allows great flexibility on customising the code, especially when developing for different platforms and MCUs.

An easy solution is described at the section Insert #include Statements from Code Snippet . For more information,

The standard IDEs often require to close one IDE and open another.

Avoid Spaces and Special Characters in Projects Name and Path

The standard IDEs, as well as the tool-chains they use, don’t support spaces and special characters in the name and path of the project, although embedXcode manages them.

A good idea is to replace spaces by underscores. For example, rename embed 1 to embed_1.

In order to ensure compatibility, it is highly recommended to avoid spaces and special characters in the name and path of the projects.

Similarly, avoid spaces in the name and path of the sketchbook folder.

Use embedXcode Pre-Processing Variable

A project using embedXcode includes the pre-processing variable EMBEDXCODE, with the release number as value.

EMBEDXCODE = 105

The variable and the value are passed on to the compiler and the linker as a -D variable.

-DEMBEDXCODE=105

This allows you to manage conditional pre-processing statements as #define and #include based on the IDE you use, either Xcode or one of the large Processing-based Wiring-derived Arduino-like IDEs family.

The EMBEDXCODE variable is already used in the main.cpp code file so it is only considered when compiled by Xcode, and ignored by the other IDEs.