Studio:Understanding SCL conflicts

From STRIDE Wiki
Revision as of 00:32, 11 March 2008 by Timd (talk | contribs)
Jump to navigation Jump to search

There is a new class of conflicts reported by the compiler called SCL conflicts. These conflicts are caused when two or more top-level header files contain conflicting constant values or pragmatized types. These were silently ignored in previous versions of STRIDE.

There are two types of SCL conflicts:

  1. The value of an enumeration constant or numeric valued preprocessor macro is in conflict with the results of the compilation of two top-level header files. A warning will be issued indicating the name associated with the inconsistent values. The compilation will still be successful, as this is only a warning; however, the value for the constant stored in ascript.Constants() will be the string “ERROR_VALUE_CONFLICT” rather than either of the original conflicting numeric values. In previous versions of STRIDE, the second value was accepted by default.
  2. A type, T, occurs in two different top-level header files and is structurally different in both. This structural difference can be caused by inconsistent or conflicting SCL pragmas applied to the type, or it can be caused by a C language difference between the types. This type of conflict is considered an error; therefore, the compilation fails and error message is returned.
  3. Example 1 The following example uses two top-level header files, Header1.h and Header2.h. Header1.h
    #define A 1
    

    Header2.h

    #define A 2
    

    The compilation of workspace 1 (via Header1.h) will return a Merge Conflict warning for “A”. The compilation will still be successful; the value of “A” in ascript.Constants() will be the string “ERROR_VALUE_CONFLICT”. Example 2 The following example uses two top-level header files, Header1.h and Header2.h, and one header file that is not a top-level header file, NotTopLevelHeader.h. Header1.h

    #include "NotTopLevelHeader.h"
    #pragma scl_ptr (S.p, OUT, PRIVATE);
    int f (S s);
    #pragma scl_function(f);
    

    Header2.h

    #include "NotTopLevelHeader.h"
    int g (S s);
    #pragma scl_function(g);
    

    NotTopLevelHeader.h

    typedef struct S {int *p;} S;
    

    As a result of the functions f() and g() having a different picture of the shared type S, the compilation fails and returns the following Merge Error:

    ... \header1.h(0) : Error : Merge conflict -- Found conflicting destinations for scl_ptr(S.p, ... )