Universal constants
arbelaezc
Posts: 12
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?
0
Comments
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.
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.
You only need to include it once, preferably as the very first include in your main AXS master file.
Wrap the constant declarations in your .axi in preprocessor directives as follows:
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):
But will throw the compiler error you mentioned if it encounters two declarations of the same constant with different initialisers (such as this):
So I'm a little concerned that you may have two constants with the same name being defined with different values in your code.
Well, I'll be damned, I am going to have to start doing that to make my life easier.
Jimmy
I am getting and internal compiler error. (C10580)
Here is my Constants.axi code:
Here is my RM205.axi:
what am I doing wrong?
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:
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:
Room code (all are the same):
Constants.axi:
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.
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.
Thanks Joe! I did have the a function whose name I never changed. All the code compiled. Now to test. Thanks again everyone!
That is what I was going to suggest as well. Two like named functions = major error.