From: Agusril on 11 Mar 2010 03:25 is this normal in visual studio.net 2008 using c++, the code below compile happily?: ---- void fff(const wchar_t* const format,...) { } int main(int argc,char*[]) { fff(false,L"abc"); return 0; } ------ thx, ag --- news://freenews.netfront.net/ - complaints: news(a)netfront.net ---
From: Agusril on 11 Mar 2010 03:33 i just check with this, it's also compiled: wchar_t* xyz = false; char* uvw = false; it seems, false, which is a bool type value, translate by compiler into zero! --- news://freenews.netfront.net/ - complaints: news(a)netfront.net ---
From: Ulrich Eckhardt on 11 Mar 2010 06:27 Agusril wrote: > i just check with this, it's also compiled: > > wchar_t* xyz = false; > char* uvw = false; > > it seems, false, which is a bool type value, translate by compiler into > zero! Any (integral?) constant with the value zero translates to a null pointer constant: void* ptr; int const i0 = 0; int const i1 = 1; ptr = i0; // okay ptr = i1; // error ptr = false; // false==0, okay ptr = true; // true==1, error Uli -- Sator Laser GmbH Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932
From: Ulrich Eckhardt on 11 Mar 2010 07:29 Ulrich Eckhardt wrote: > Agusril wrote: >> it seems, false, which is a bool type value, translate by compiler into >> zero! > > Any (integral?) constant with the value zero translates to a null pointer > constant: [...] BTW: If you want a full explanation including chapter and verse from the C++ standard, you should ask in comp.lang.c++.moderated. Uli -- Sator Laser GmbH Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932
From: Agusril on 11 Mar 2010 18:47 Okay, thx. I would. I just wandering why, if a constant value of bool, true and false, and variable of typed bool treated differently. It's my fault. Because i have a difficult time try to figure out why my program crash when try log something. And i found out it's because of this. void ff(bool boolval,const wchar_t* const format,...) { } void ff(const wchar_t* const format,...) { //never check the format value here. } somehere else in my coding i call with this: ff(false,L"bla bla bla,..."); and after a while with this two function, for some reason, i removed the first one, missed to remove false from the caller, and compiled the program. and because of this feature, the program compiled and run without problem until sometimes, it hits the function without bool type parameter. and voila, it crash, because the value for format is NULL. it's just pain killer for the headache i've got. But, thx for the referred group. "Ulrich Eckhardt" <eckhardt(a)satorlaser.com> wrote in message news:pa4n67-p4i.ln1(a)satorlaser.homedns.org... > Ulrich Eckhardt wrote: >> Agusril wrote: >>> it seems, false, which is a bool type value, translate by compiler into >>> zero! >> >> Any (integral?) constant with the value zero translates to a null pointer >> constant: > [...] > > BTW: If you want a full explanation including chapter and verse from the > C++ > standard, you should ask in comp.lang.c++.moderated. > > Uli > > -- > Sator Laser GmbH > Gesch�ftsf�hrer: Thorsten F�cking, Amtsgericht Hamburg HR B62 932 > --- news://freenews.netfront.net/ - complaints: news(a)netfront.net ---
|
Pages: 1 Prev: How to iterate the vtable of COM coclass? Next: Help - trying to create a very basic renderer |