Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X
The header file for creating Custom Functions (Prime) or User DLLs (Mcad15) creates three pre-compiler defines to facilitate telling function definitions what type of parameters are being passed; Complex scalar, complex array, or string. These definitions
#define COMPLEX_SCALAR 1 // Used to indicate an COMLEXSCALAR type
#define COMPLEX_ARRAY 2 // Used to indicate an COMPLEXARRAY type
#define STRING 8 // Used to indicate an MCSTRING type
are not used anywhere else in the header file and are for user convenience only. However, STRING is a very common name and has a high probability of conflicting with other code that is being linked in or included (I've already had an issue). Following the example of the first two defines, a far better choice would be to define:
#define MC_STRING 8 // Used to indicate an MCSTRING type
This would have a much lower probability of conflicting with another definition of STRING in another construct being used, and clearly identify the variable as belonging to Mathcad.
Additionally, the pre-processor turns this into a hard coded value wherever it is used, which can be hard to track down and find. A better programming practice for debugging (see http://stackoverflow.com/questions/136946/difference-between-enum-and-define-statements) is to use enumerations rather than defines, like so:
enum MCTypes {COMPLEX_SCALAR =1, COMPLEX_ARRAY, MC_STRING = 8}; // To define all three parameter types
At this point, mcadincl.h is identical between Prime and Mcad15, so this enhancement is recommended for both codes.
Workaround
Until then, for any users who are interested, you can fix this potential conflict by replacing #include <mcadincl.h> with the following in your code:
#include <mcadincl.h> // creates STRING constant
enum { MC_STRING = STRING }; // To define replacement MC_STRING parameter types
#undef STRING // to free up this STRING definition, use MC_STRING in program
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.