IonicWind Software

IWBasic => General Questions => Topic started by: Andy on November 15, 2016, 12:19:05 AM

Title: Using $Define etc
Post by: Andy on November 15, 2016, 12:19:05 AM
I'm working on updating my Registry.inc file and I want to bring it in line with the built in IWB registry functions such as:

KeyName
Entry
Value.

That should be simple enough for me to do, but I have a problem with windowssdk.inc

Most of us use this include file as a matter of course, the problem is that windowssdk.inc also includes winreg.inc which has duplicate declarations such as RegCreateKey, RegGetValue etc.

So, if you define windowssdk.inc BEFORE Registry.inc in your program you will get compile errors.

How do I change my Registry.inc file so that if someone defines windowssdk.inc in their code, it won't give compile errors without renaming my functions in Registry.inc?
can that be done? 

Attached is the Registry.inc file i'm working on and a little program to use the registry.inc file.

In this little program, i'm experimenting on placing the windowssdk.inc BOTH before AND after Registry.inc.

Attached is the code.

Just try compiling RegTest.iwb - no need to execute it, and then repeat the process with windowssdk.inc UNDER Registry.inc

Thanks,
Andy.



Title: Re: Using $Define etc
Post by: LarryMc on November 15, 2016, 10:37:13 PM
In my opinion you have two possible solutions:
1) Rename your subroutines to get rid of the conflicts
2) Create two Registry.inc files
    1 to use with widowssdk.inc and one to use without it.

The reason is:
$define constants are local to the source file that they are defined in.
so one defined in the windowssdk.inc file can't be seen in the registry.inc file
I even tried passing from windowssdk.inc to parent then parent to registry.inc and that doesn't work
Now if you had a project you could put a $define in a global source file and include that in all the other files and make it work but I don't think that is the way to go with your offering.

I think either of my 2 suggestions above is acceptable.
Title: Re: Using $Define etc
Post by: Andy on November 16, 2016, 06:46:37 AM
Larry,

In the end, I've decided to go for option 1, so I'm renaming the subroutines and getting rid of any conflicts with windowssdk.inc.

Thanks for the suggestion, in the end I think it was the best option.

Andy.