I can't believe that I spent around 6 hours to debug this error code. Though I am just beginning with C++, its too long a time. I greped over the internet and the root cause as mentioned is
"this linker error will occur when a virtual function is not defined". I checked my class definition over and over and made very sure the all the virtual functions are defined in the base class. huhh i did that and this and was running out of options. tried sample programs and all went fine.
Then i took deep breath and was rolling over other files in the codebase and '#pragma interface" seemed to be something new to me. I tried googling it and found something interesting with gcc. Looks like the compiler will cache auxillary information and during the linking time, this cached information is used. In my case, the cached information may not have been the correct one. When we use this pragma, it forces gcc not to do any caching and hence force 'ld' to do the linking dynamically.
and this has done the trick for me.
Tuesday, May 26, 2009
Wednesday, May 13, 2009
"unterminated character constant" c++
I got this error message recently. I was scratching my head of what this hell is all about as the error line pointed to an unrelated line of code. After digging through I found its because of an unterminated character sequence in the previous function.
eg. cout << "blah .. << endl;
eg. cout << "blah .. << endl;
Monday, May 11, 2009
IP to Int conversion tool
most often when we are programming in networking, we might want to convert IP to interger and vice versa. Earlier I used to have a c program to do this task for me. I somehow lost it and now I needed for a quick reference and found this URL serving my purpose.
http://andrey.mikhalchuk.com/2008/01/28/simple-free-online-ip-conversion-tool.html
http://andrey.mikhalchuk.com/2008/01/28/simple-free-online-ip-conversion-tool.html
loop over enum C/C++
i was expecting enum to be treated as integer as using it in my code as,
for ( enumA i=0, i< enumMax ; i++)
Only after compiler scolding me, I realized that post-increment will not work with enum :-)
so here is how we can overcome this,
for ( enumA i=0, i< enumMax ; i = enumA( i+1))
And remember enum is a datatype and so operator overloading over an enum is not possible and hence you can not overload ++ operator also.
for ( enumA i=0, i< enumMax ; i++)
Only after compiler scolding me, I realized that post-increment will not work with enum :-)
so here is how we can overcome this,
for ( enumA i=0, i< enumMax ; i = enumA( i+1))
And remember enum is a datatype and so operator overloading over an enum is not possible and hence you can not overload ++ operator also.
Subscribe to:
Comments (Atom)
