Studio:Understanding SCL conflicts: Difference between revisions
No edit summary |
m (Text replace - 'Category:Workarounds' to 'Category:Studio:Workarounds') |
||
(5 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
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 | 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 types that have had inconsistent pragmas applied between compilation units. These were silently ignored in previous versions of STRIDE. | ||
There are two types of SCL conflicts: | There are two types of SCL conflicts: | ||
<ol> | <ol> | ||
<li>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.</li> | <li>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.</li> | ||
<li>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.</li> | <li>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.</li> | ||
'''Example 1''' | '''Example 1''' | ||
The following example uses two top-level header files, Header1.h and Header2.h. | The following example uses two top-level header files, Header1.h and Header2.h. | ||
''Header1.h'' | ''Header1.h'' | ||
<source lang="c"> | |||
#define A 1 | |||
</source> | |||
''Header2.h'' | ''Header2.h'' | ||
<source lang="c"> | |||
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”. | #define A 2 | ||
'''Example 2''' | </source> | ||
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. | 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'' | ''Header1.h'' | ||
<source lang="c"> | |||
#include "NotTopLevelHeader.h" | |||
#pragma scl_ptr (S.p, OUT, PRIVATE); | |||
int f (S s); | |||
#pragma scl_function(f); | |||
</source> | |||
''Header2.h'' | ''Header2.h'' | ||
<source lang="c"> | |||
#include "NotTopLevelHeader.h" | |||
int g (S s); | |||
#pragma scl_function(g); | |||
</source> | |||
''NotTopLevelHeader.h'' | ''NotTopLevelHeader.h'' | ||
<source lang="c"> | |||
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:< | typedef struct S {int *p;} S; | ||
</source> | |||
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: | |||
<pre> | |||
... \header1.h(0) : Error : Merge conflict -- Found conflicting destinations for scl_ptr(S.p, ... ) | |||
[[Category: | </pre> | ||
[[Category:Studio:Workarounds]] |
Latest revision as of 00:13, 21 August 2009
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 types that have had inconsistent pragmas applied between compilation units. These were silently ignored in previous versions of STRIDE.
There are two types of SCL conflicts:
- 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.
- 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. 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, ... )