April 18, 2024, 02:17:01 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Using $Define etc

Started by Andy, November 15, 2016, 12:19:05 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy

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.



Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

LarryMc

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.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Andy

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.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.