![]() |
![]() HP OpenVMS Systemsask the wizard |
![]() |
The Question is: This is for C. Is it possible to use the same variable name defined by the system h files and redefine it of diff type in my local program. For example index is defined in string.h as char *index in my local program I have index defined as long index. And stingh.h is one of the include files Compiler gives an error saying not compatable How can I get around this thanks The Answer is : Duplicating variables with declarations from the header files or from the C standard library is inadvisable practice. If you wish to perform this practice, you will want to comment your code clearly, and become familiar with the scope rules used for the declaration of and the use of variables. The particular declaration you reference in string.h is the index function, not the index variable. It would also appear your variable may be of external scope. Recent versions of C allow you to have external variables that overlap function names, though the Wizard still views this practice as inadvisable. Prior to the versions with separate scopes, you will want to use the /PREFIX qualifier to suppress the prefix on the specified external variable. When posting a question such as this, please include the relevent product versions such as the compiler version, a short reproducer, and the complete text of the error message(s) generated.
|