Universal constants
arbelaezc
Junior Member
I am looking to use a set of constants all of my .axi files in my system. I created a constants.axi that held all of my constant and included it into my other .axi files where the code will call them. When including those set of axi into my axs, I am receiving an error that symbol [defined_constant] is already defined. Any suggestions on how to create it?
Comments
-
I am looking to use a set of constants all of my .axi files in my system. I created a constants.axi that held all of my constant and included it into my other .axi files where the code will call them. When including those set of axi into my axs, I am receiving an error that symbol [defined_constant] is already defined. Any suggestions on how to create it?
More than likely you have a constant(s) declared in some other include or in the main file. Bret thing to do is just do a 'find' by whatever the variable name is. It also might be defined as a var or local or stack var. -
I am looking to use a set of constants all of my .axi files in my system. I created a constants.axi that held all of my constant and included it into my other .axi files where the code will call them. When including those set of axi into my axs, I am receiving an error that symbol [defined_constant] is already defined. Any suggestions on how to create it?
The include file with the constant declarations only needs to be included once, not in every include file.
Make your declaration include the first one in your main program and it will populate all of the definitions into each include file that follows it. -
included it into my other .axi files where the code will call them.
You only need to include it once, preferably as the very first include in your main AXS master file. -
When including those set of axi into my axs, I am receiving an error that symbol [defined_constant] is already defined. Any suggestions on how to create it?
Wrap the constant declarations in your .axi in preprocessor directives as follows:#IF_NOT_DEFINED __CONSTANTS_AXI__ #DEFINE __CONSTANTS_AXI__ DEFINE_CONSTANT // Include your constant definitions here #END_IF
The code wrapped in the #IF_NOT_DEFINED block will only ever be included in the compilation once hence your compilation error shouldn't keep occurring. If it does, you must have an extraneous declaration of that constant somewhere else in your code.
From memory the NetLinx compiler is fairly tolerant and will compile two declarations of the same constant with the same initialiser (like the following):DEFINE_CONSTANT A_CONSTANT = 1 A_CONSTANT = 1
But will throw the compiler error you mentioned if it encounters two declarations of the same constant with different initialisers (such as this):DEFINE_CONSTANT A_CONSTANT = 1 A_CONSTANT = 2
So I'm a little concerned that you may have two constants with the same name being defined with different values in your code. -
I use the preprocessor directives on almost all my includes specifically so I can put the #include statement in every file so that studio will correctly highlight and auto-complete the contents of the include file.
-
I also do this for module parameters with out initialization values since there's no need for them.I use the preprocessor directives on almost all my includes specifically so I can put the #include statement in every file so that studio will correctly highlight and auto-complete the contents of the include file.MODULE_NAME='VAV_Oppo_DVD_Mod,Rev0'(DEV vDEVcomm,DEV dvDEV,INTEGER nInstance,CHAR cIP[],INTEGER nComType,INTEGER nDeBug) DEFINE_DEVICE //#DEFINE DEFINE_MODULE_PARAMETERS //THIS JUST ALLOWS HIGHLIGHTING & AUTOCOMPLETE ITEMS PASSED IN THE HEADER #DEFINE DEFINE_MODULE_PARAMETERS #IF_NOT_DEFINED DEFINE_MODULE_PARAMETERS vDEVcomm dvDEV #END_IF DEFINE_VARIABLE //MODULE HEADER PARAMETERS //THIS JUST ALLOWS HIGHLIGHTING & AUTOCOMPLETE ITEMS PASSED IN THE HEADER #DEFINE DEFINE_MODULE_PARAMETERS #IF_NOT_DEFINED DEFINE_MODULE_PARAMETERS nInstance cIP nDeBug nComType #END_IF
-
I also do this for module parameters with out initialization values since there's no need for them.
Well, I'll be damned, I am going to have to start doing that to make my life easier.
Jimmy -
So where exactly do I put the include in? This is how I have it:
PROGRAM_NAME='West_Source' DEFINE_CONSTANT //----------------------------------------- #INCLUDE 'Constants.axi' DEFINE_TYPE //--------------------------------------------- DEFINE_VARIABLE //----------------------------------------- DEFINE_LATCHING //----------------------------------------- DEFINE_MUTUALLY_EXCLUSIVE //------------------------------- #include 'RM205.axi'
I am getting and internal compiler error. (C10580)
Here is my Constants.axi code:PROGRAM_NAME='Constants' DEFINE_CONSTANT //-------------------------------------------------------- #DEFINE MY_CONSTANTS //constants go here
Here is my RM205.axi:PROGRAM_NAME='RM205' DEFINE_CONSTANT //-------------------------------------------------------- #IF_NOT_DEFINED MY_CONSTANTS
what am I doing wrong? -
Wrap the constant declarations in your .axi in preprocessor directives as follows:
#IF_NOT_DEFINED __CONSTANTS_AXI__ #DEFINE __CONSTANTS_AXI__ DEFINE_CONSTANT // Include your constant definitions here #END_IF
Do I include that in all my AXIs? -
Do I include that in all my AXIs?
Only in your constants.axi file.
Add the #IF_NOT_DEFINED/#DEFINE lines to the top of the file and the #END_IF directive to the bottom of the file like this:#IF_NOT_DEFINED __CONSTANTS_AXI__ #DEFINE __CONSTANTS_AXI__ DEFINE_CONSTANT // Include your constant definitions here CONSTANT_A = 1 CONSTANT_B = 2 [etc...] #END_IF
These pre-processor directives ensure that the block of code they enclose will only be included in the compilation once, no matter how many times you #include the file that code resides in in other source files. -
Auser has the right idea here. Consider this to be me hitting the Like button.
-
Only in your constants.axi file.
Add the #IF_NOT_DEFINED/#DEFINE lines to the top of the file and the #END_IF directive to the bottom of the file like this:#IF_NOT_DEFINED __CONSTANTS_AXI__ #DEFINE __CONSTANTS_AXI__ DEFINE_CONSTANT // Include your constant definitions here CONSTANT_A = 1 CONSTANT_B = 2 [etc...] #END_IF
These pre-processor directives ensure that the block of code they enclose will only be included in the compilation once, no matter how many times you #include the file that code resides in in other source files.
I #include my Constants.axi file in all the .axi files including the master .axs and am still getting and error code.
ERROR: (0): C10580: Internal Error: Major system error occurred during code generation
I still must be doing something wrong. I'll show you what I have.
Master:PROGRAM_NAME='West_Source' DEFINE_DEVICE //------------------------------------------- //devices DEFINE_CONSTANT //----------------------------------------- #INCLUDE 'Constants.axi' DEFINE_TYPE //--------------------------------------------- DEFINE_VARIABLE //----------------------------------------- DEFINE_LATCHING //----------------------------------------- DEFINE_MUTUALLY_EXCLUSIVE //------------------------------- #INCLUDE 'RM205.axi' #INCLUDE 'RM206.axi' #INCLUDE 'RM209A.axi' #INCLUDE 'RM209.axi' #INCLUDE 'RM213.axi' #INCLUDE 'RM214.axi' //rest of program
Room code (all are the same):PROGRAM_NAME='RM205' DEFINE_DEVICE //---------------------------------------------------------- //devices DEFINE_CONSTANT //-------------------------------------------------------- #INCLUDE 'Constants.axi' //rest of code
Constants.axi:PROGRAM_NAME='Constants' #IF_NOT_DEFINED MY_CONSTANTS #DEFINE MY_CONSTANTS DEFINE_CONSTANT //constants definitions #END_IF
-
I #include my Constants.axi file in all the .axi files including the master .axs and am still getting and error code.
ERROR: (0): C10580: Internal Error: Major system error occurred during code generation
That has to be in the running for the most unhelpful error message ever.
Best way I know of to hunt for this error is to comment out every include statement in your program and add them back one at a time until you see the error so you at least have a vague clue where to start looking for the thing. -
ERROR: (0): C10580: Internal Error: Major system error occurred during code generation
I'm sure there are other reasons but I know that two functions with the same name will cause that error. -
Joe Hebert wrote: »I'm sure there are other reasons but I know that two functions with the same name will cause that error.
Yup, think that's the only time(s) I've seen that error. -
Joe Hebert wrote: »I'm sure there are other reasons but I know that two functions with the same name will cause that error.
Thanks Joe! I did have the a function whose name I never changed. All the code compiled. Now to test. Thanks again everyone! -
Joe Hebert wrote: »I'm sure there are other reasons but I know that two functions with the same name will cause that error.
That is what I was going to suggest as well. Two like named functions = major error.
Categories
- All Categories
- 2.5K AMX General Discussion
- 922 AMX Technical Discussion
- 514 AMX Hardware
- 502 AMX Control Products
- 3 AMX Video Distribution Products
- 9 AMX Networked AV (SVSI) Products
- AMX Workspace & Collaboration Products
- 3.4K AMX Software
- 151 AMX Resource Management Suite Software
- 386 AMX Design Tools
- 2.4K NetLinx Studio
- 135 Duet/Cafe Duet
- 248 NetLinx Modules & Duet Modules
- 57 AMX RPM Forum
- 228 MODPEDIA - The Public Repository of Modules for Everyone
- 943 AMX Specialty Forums
- 2.6K AMXForums Archive
- 2.6K AMXForums Archive Threads
- 1.5K AMX Hardware
- 432 AMX Applications and Solutions
- 249 Residential Forum
- 182 Tips and Tricks
- 146 AMX Website/Forums

