www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Mixin strange behaviour (was Mixin bug, but this time i've got the real problem, read please)

reply Lox TG <Lox_member pathlink.com> writes:
Hi to all,
i'm back to the forum to ask a question about mixins 'cuz i've found something
strange:

/*--------------------------
test 1
-------------------------*/

template Macro(alias a)
{
int main(char[][] args)
{
a();
return 0;
{
}

int Foo()
{
return 3;
}

mixin Macro!(Foo);

/*----------------------------*/

it compiles flawlessy, no problem in inlining the parametrized mixin code as te
executable's main function, but when it comes to Win32 programming something
strange happens:

/*----------------------------
test 2
----------------------------*/

import std.c.windows.windows;


extern (C) void gc_init();
extern (C) void gc_term();
extern (C) void _minit();
extern (C) void _moduleCtor();
extern (C) void _moduleUnitTests();

template Macro(alias a)
{
extern (Windows)
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int
nCmdShow)
{
int result;

gc_init();			// initialize garbage collector
_minit();			// initialize module constructor table

try
{
_moduleCtor();		// call module constructors
_moduleUnitTests();	// run unit tests (optional)

result = a(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
}

catch (Object o)		// catch any uncaught exceptions
{
//MessageBoxW(null, cast(wchar *)o.toString(), "Error", MB_OK |
MB_ICONEXCLAMATION);
result = 0;		// failed
}

gc_term();			// run finalizers; terminate garbage collector
return result;
}
}

int pippo(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int
nCmdShow)
{
return 3;
}

mixin Macro!(pippo);

/*-----------------------------------*/

now the strange thing: the linker cannot find _WinMain 16 simbol and reference.
After some tests I've found that it acts like the extern(Windows) attribute is
ignored. So I've tried putting it on both the template definition and the mixin
statement but there was nothing to do :-(

Now the question:

Is this a bug? Can it be solved? Or there's a way to get around it?


"When Rome will Fall
Then the World."
Mar 16 2005
parent reply Manfred Nowak <svv1999 hotmail.com> writes:
Lox TG <Lox_member pathlink.com> wrote:

[...]
 found something strange:

Would you please post here only if you are _sure_, that you are _not_ describing a bug. Otherwise send your posts to the digitalmars.bugs- NG please. There are similar posts already. For example: digitalmars.D.bugs/1686 -manfred
Mar 16 2005
parent reply J C Calvarese <jcc7 cox.net> writes:
Manfred Nowak wrote:
 Lox TG <Lox_member pathlink.com> wrote:
 
 [...]
 
found something strange:

[...] Would you please post here only if you are _sure_, that you are _not_ describing a bug. Otherwise send your posts to the digitalmars.bugs- NG please.

Sometimes mere mortals don't know if it's a bug or not until after they post it.
 There are similar posts already. For example:
 digitalmars.D.bugs/1686
 
 -manfred

-- Justin (a/k/a jcc7) http://jcc_7.tripod.com/d/
Mar 16 2005
next sibling parent Lox TG <Lox_member pathlink.com> writes:
In article <d1bb4u$5u0$2 digitaldaemon.com>, J C Calvarese says...
Manfred Nowak wrote:
 Lox TG <Lox_member pathlink.com> wrote:
 
 [...]
 
found something strange:

[...] Would you please post here only if you are _sure_, that you are _not_ describing a bug. Otherwise send your posts to the digitalmars.bugs- NG please.

Sometimes mere mortals don't know if it's a bug or not until after they post it.
 There are similar posts already. For example:
 digitalmars.D.bugs/1686
 
 -manfred

-- Justin (a/k/a jcc7) http://jcc_7.tripod.com/d/

Mar 17 2005
prev sibling parent reply Lox TG <Lox_member pathlink.com> writes:
In article <d1bb4u$5u0$2 digitaldaemon.com>, J C Calvarese says...
Manfred Nowak wrote:
 Lox TG <Lox_member pathlink.com> wrote:
 
 [...]
 
found something strange:

[...] Would you please post here only if you are _sure_, that you are _not_ describing a bug. Otherwise send your posts to the digitalmars.bugs- NG please.

Sometimes mere mortals don't know if it's a bug or not until after they post it.
 There are similar posts already. For example:
 digitalmars.D.bugs/1686
 
 -manfred

-- Justin (a/k/a jcc7) http://jcc_7.tripod.com/d/

Pardonez moi, mea culpa, mea maxima culpa. It seems that folks on this forum are very good at welcoming newbies. Anyone thought that I couldn't know if it is a bug or not? Maybe it is a rule "Do not use mixins' parametrized code with a linkage other than D", the docs on the site seems not to be always so specific to me (let's say that they're not the same as VC++ online help ;-)). It seemed to me that doing some investigation on this strange behaviour prior to bothering the guys at DM posting it as a bug on the dedicated forum (YES, I know that it exists and that there are similar posts on it, but you wrote right, SIMILAR, full stop. I've haven't found a bug post dealing woth Windows linkage in mixins). If you feel being bothered from SIMILAR question (Oh, what a crime) you have the right to ignore them. There's no reason to laugh at us "mere mortals", as you said (I'm wondering if it make you feel a REAL pro :-D). Still very impressed though. "When Rome will Fall Then the World"
Mar 17 2005
parent reply Manfred Nowak <svv1999 hotmail.com> writes:
Lox TG <Lox_member pathlink.com> wrote:

[...]
 I couldn't know if it is a bug or not? Maybe

 bothering the guys at DM posting it as a bug on the dedicated
 forum 

This has nothing to do with you yourself declaring as a newbie to D. But rather with the rules of thumb existing in news groups: Using fake names is impolite. Using fake email adresses is impolite. Cross posting is impolite. Posting to general NG, if there is a dedicated NG, is impolite. Making wrong statements and not excusing is impolite. Beginning a new thread and not leading it is impolite. Beginning a new thread on nearly the same subject after a few days is impolite. People who start to flame, when they get a hint that they might not have followed the rules of thumb, are impolite. Impolite people are considered as spam and plonked or forwarded to clown groups. Decide yourself how you want your posts to be treated. -manfred
Mar 17 2005
next sibling parent Derek Parnell <derek psych.ward> writes:
On Thu, 17 Mar 2005 11:30:36 +0000 (UTC), Manfred Nowak wrote:

[snip]

 Decide yourself how you want your posts to be treated.
 
 -manfred

Do worry yourself too much over Manfred's enthusiasm; he's mostly harmless even though he comes across as a bit Teutonic at times. He sincerely means well, so don't take it personally. Me, however...I'm impolite, disrespectful to self-important people, and basically full of shit, IMNSHO ;-) So don't listen to my chaff and rubbish. -- Derek Parnell Melbourne, Australia http://www.dsource.org/projects/build 18/03/2005 12:51:29 AM
Mar 17 2005
prev sibling next sibling parent reply Lox TG <Lox_member pathlink.com> writes:
Firstable there's no rule page for this forum in the DM site, so all the
beautiful things you wrote are only useless chars in a remote DB ;-)

However:

Using fake names is impolite.

I've taken a look in the forum and found that there's not only me using a NICKname, and it seems to be a normal thing to use a NICKname in forums, chats, newsgroups and mailinglists.
Using fake email adresses is impolite.

Sorry but my account is just full of spam, don't wat any other :-) And it was not fake, just didn't entered it.
Cross posting is impolite.

I'm used to PHPBB, this forum has a simpler but different interface, I made some confusion with the buttons but I'm managing to getting used to it, I know I can do it :-D
Posting to general NG, if there is a dedicated NG, is impolite.

Oh God of the gods, will he never understand? I didn't know if it was a bug or not and seems to me very IMPOLITE to post as a bug without have ever asked someone else if he knows it is or not. ;-)
Making wrong statements and not excusing is impolite.

You think that writing "Yo stupid guy, post this scrap elsewhere" without answering at the question is POLITE? And insulting people with things like "mere mortals"? I think not ;-)
Beginning a new thread and not leading it is impolite.

Again, I'm getting used to this forum interface.
Beginning a new thread on nearly the same subject after a few days
is impolite.

If the server didn't blocked it, it means i can do it, and the new post was made 'cuz nearly noone replied (except You, if i'm not making a mistake, so thnx very much, but it was enough evident that it was not a problem of type definition, Win32 programming in D is still doable without importing the useless std.c.windows.windows module and the OPTLINK linker) and I had new clues about the problem, needed to attract your attention ;-)
People who start to flame, when they get a hint that
they might not have followed the rules of thumb, are impolite.

People who continue to flame are IMPOLITE, aren't they? :-)
Impolite people are considered as spam and plonked or forwarded to
clown groups.

Ok, let's have a beer next time we'll meet to the circus for work, I'll pay for you too, OK? :-D
Decide yourself how you want your posts to be treated.

I've decided, but you have to take a decision too, decide how you want to take care of new user of D, it could have consequencies on the language diffusion over time ;-)
Do not worry yourself too much over Manfred's enthusiasm

Thnx Derek (can I call you Derek? I don't want to seem IMPOLITE ;-) ), but I'm not taking the risk :-) Stil very very impressed though. "When Rome will Fall Then the World"
Mar 17 2005
next sibling parent J C Calvarese <jcc7 cox.net> writes:
In article <d1c4mn$12ml$1 digitaldaemon.com>, Lox TG says...
..
You think that writing "Yo stupid guy, post this scrap elsewhere" without
answering at the question is POLITE? And insulting people with things like "mere
mortals"? I think not ;-)

Please calm down a little. Manfred is obnoxious to everyone. Don't feel like you're be singled out. By the way, I was the guy wrote "mere mortals" and it was directed at Manfred--not you. I was hinting to him that we don't all consider ourselves to be programming gods, and he should cut the rest of us some slack. If it was insulting, it definitely wasn't meant to insulting to you (unless you consider yourself to be immortal, in which case I hope you have time to forgive all of us for the misunderstanding). jcc7
Mar 17 2005
prev sibling parent reply Manfred Nowak <svv1999 hotmail.com> writes:
Lox TG <Lox_member pathlink.com> wrote:

 Firstable there's no rule page for this forum in the DM site, so
 all the beautiful things you wrote are only useless chars in a
 remote DB ;-) 

I see. Could it be that you are one of these guys who need signs on the walls everywhere? Do you frequently notice, that people stand up and leave when you just sat down? Do you frequently notice, that when you greet people on the road, they do not greet back? Can it be that, if one day somebody will not stand up or will greet back and in addition remarks that incredible body smell makes people lonely, you would bark at him, that there are no signs at the wall that disallow you to have body smell? You are welcome to do what you like, iff you accept that others also do what they like. -manfred
Mar 17 2005
parent reply Federico_Lox TG <Federico_Lox_member pathlink.com> writes:
In article <d1cu0o$1uve$1 digitaldaemon.com>, Manfred Nowak says...
Lox TG <Lox_member pathlink.com> wrote:

 Firstable there's no rule page for this forum in the DM site, so
 all the beautiful things you wrote are only useless chars in a
 remote DB ;-) 

I see. Could it be that you are one of these guys who need signs on the walls everywhere? Do you frequently notice, that people stand up and leave when you just sat down? Do you frequently notice, that when you greet people on the road, they do not greet back? Can it be that, if one day somebody will not stand up or will greet back and in addition remarks that incredible body smell makes people lonely, you would bark at him, that there are no signs at the wall that disallow you to have body smell? You are welcome to do what you like, iff you accept that others also do what they like. -manfred

Still laughing till madness :-D You're not so bad in the end ;-) More impressed than before. "When Rome will Fall Then the World"
Mar 17 2005
parent Thomas Kuehne <thomas-dloop kuehne.thisisspam.cn> writes:
 "When Rome will Fall
 Then the World"

http://anime-empire.kicks-ass.net/404.php Read on for a seccond or 2
Mar 17 2005
prev sibling parent reply Georg Wrede <georg.wrede nospam.org> writes:
Manfred Nowak wrote:
 Lox TG <Lox_member pathlink.com> wrote:
 
 [...]
 
I couldn't know if it is a bug or not? Maybe

[...]
bothering the guys at DM posting it as a bug on the dedicated
forum 

[...] This has nothing to do with you yourself declaring as a newbie to D. But rather with the rules of thumb existing in news groups: Using fake names is impolite. Using fake email adresses is impolite. Cross posting is impolite. Posting to general NG, if there is a dedicated NG, is impolite. Making wrong statements and not excusing is impolite. Beginning a new thread and not leading it is impolite. Beginning a new thread on nearly the same subject after a few days is impolite. People who start to flame, when they get a hint that they might not have followed the rules of thumb, are impolite. Impolite people are considered as spam and plonked or forwarded to clown groups. Decide yourself how you want your posts to be treated. -manfred

Manfred, please! Up till we got the new newsgroups, this NG has had an exceptional reputation for being polite, to the point, and helpful. Let's not create a warzone here. And let's not give D a bad reputation for being "only a language for hostile and aggressive insiders", unwelcoming the unsuspecting. --------------- If new people have a hard time getting our Rules right, then we should, (or actually *Walter* should) fix it! How do people find these pages? Is it via Links on DM, for example. If it is, then there should be information on what we want and do not want on a particular NG. In any case, there should be one page where these rules (or, I'd more like the word "guide lines") are posted. Instead of telling people to f**k off, we could just refer them to that page. --------------- P.S: Ok, I've done my share of posting when tired or in a hangover. (Most notably in early 2003, when I totally misrepresented the meaning of float cast to int (or something).) I was so ashamed I didn't post anything here for 6 months. (Check the records.) There was also (I think before Christmas) a post "D is doomed" or something, with a false name, which (probably) was written both angry and drunk. We all have our guesses on who that was, but we never beat the guy out of this NG either.
Mar 21 2005
parent Manfred Nowak <svv1999 hotmail.com> writes:
Georg Wrede <georg.wrede nospam.org> wrote:

[...]
 In any case, there should be one page where these rules (or, I'd
 more like the word "guide lines") are posted.
 
 Instead of telling people to f**k off, we could just refer them
 to that page.

Dear Georg, I always read your thoughts with pleasure, whether I agree or disagree in the end. Referring to a page is just including the contents of the page into the post. So it is just a matter of taste whether to consider preformulated text or individually written text more friendly. I prefer the second choice. In either case somebody has to start with expressing the unwanted. If I have choosen the wrong words the next poster can improve on them. If somebody chooses to provide a link like http://groups.google.de/groups?selm=c76017cb.0112180637.c1abdb7% 40posting.google.com&output=gplain somebody may consider the contents also as inapropriate for this NG. However, I am sure that as I did also the provider of such a link would not want to express that the originator of the incriminated post should f**k off. -manfred
Mar 21 2005