digitalmars.D - to many conflicts!!
"aelmetwaly" <aelmetwaly gawab.com> writes:
Hi, How can I import two modules contain the same definitions for some func and variables? for example import std.c.windows.windows; import win;
Sep 02 2004
J C Calvarese <jcc7 cox.net> writes:
aelmetwaly wrote:Hi, How can I import two modules contain the same definitions for some func and variables? for example import std.c.windows.windows; import win;
Here are some ideas (choose your favorite or mix-and-match): 1. Don't import std.c.windows.windows. (But I'm sure you already tried this.) 2. Don't import win (But I'm sure you already tried this, too.) 3. Use module names when accessing imported items: When you use something from win, access it like this: "win.something". When you use something from std.c.windows.windows, access it like this: "std.c.windows.windows.something" (yeah, it's a mouthful). 4. Use alias tricks to shorten module names. alias std.c.windows.windows stdw; alias win w; Now, you can access items like this: "w.something" and "stdw.something". 5. Use alias tricks to choose a "default" for each symbol: alias std.c.window.windows.something something; Now, you when you mention "something", D knows you mean "std.c.window.windows.something". 6. "version-out" the conflicting symbols within the win module: version(STANDALONE) int something(); Now, the compiler won't compile in "something" unless you compile with the STANDALONE version. I'm sure someone will remind me of all of the options that I forgot. -- Justin (a/k/a jcc7) http://jcc_7.tripod.com/d/
Sep 02 2004
Id <Id_member pathlink.com> writes:
In article <ch87sv$s7n$1 digitaldaemon.com>, aelmetwaly says...Hi, How can I import two modules contain the same definitions for some func and variables? for example import std.c.windows.windows; import win;
If the function names are the same, you just have to explicitly specify which one you are referring to: int variable=win.foo(); int another_variable=std.c.windows.windows.foo(); Note: If you find that typing std.c.windows.windows every time is annoying, you can alias it like this: alias std.c.windows.windows winfunc; then use winfunc.foo(); // refers to std.c.windows.windows.foo(); Hope it helps :) .
Sep 03 2004