Friday, December 14, 2007

C++: Borland C++ Builder Linker Errors

I kept getting these linker errors for a wrapper class I was writing.

[Linker Error] Unresolved external 'Curlit::errorBuffer' referenced from C:\PROJECTS\LIBCURL\CURLIT.OBJ
[Linker Error] Unresolved external 'Curlit::buffer' referenced from C:\PROJECTS\LIBCURL\CURLIT.OBJ

Now I thought I was just getting random linker errors. But only after I played with things a bit did I realize it was because errorBuffer and buffer were declared static.

class Curlit
{
protected:
static char errorBuffer[CURL_ERROR_SIZE];
static string buffer;
static int writer(char *data, size_t size, size_t nmemb, string *buffer);
static string easycurl(string &url, bool post, string &pstring);

public:
Curlit();
~
Curlit();
static string post(string &url, std::map<string, string> &querystr);
static string get(string &url);
static string escape(string &param);
};

Once I realized it was because they were static, I was able to put the right words into google. I soon learned that static class members, must be redeclared outside the class definition as shown below. Once I added two lines of code, the linker errors went away.

class Curlit
{
protected:
static char errorBuffer[CURL_ERROR_SIZE];
static string buffer;
static int writer(char *data, size_t size, size_t nmemb, string *buffer);
static string easycurl(string &url, bool post, string &pstring);

public:
Curlit();
~
Curlit();
static string post(string &url, std::map<string, string> &querystr);
static string get(string &url);
static string escape(string &param);
};

char Curlit::errorBuffer[CURL_ERROR_SIZE];
string Curlit::buffer;

source(s): programmersheaven.com/mb/CandCPP/67811/67811/ReadMessage.aspx

Monday, December 10, 2007

Scientists Discover How to Make Robots Bounce on Water

Scientists have discovered how water striders are able to not just walk but also bounce on water

Just check out this picture, its awesome.



source(s): http://www.environmentalgraffiti.com/?p=592

Wednesday, December 05, 2007

JS: Are you sure you want to navigate away from this page?

I've been using blogger for a while, and not because I don't know how to build my own blog or website. I've build dozens of them, but I use blogger because its easy, and I don't have to worry about the details of the code. Heck I could build a site like blogger if I wanted, it would just take time. Occasionally on blogger I bump into a feature that I don't know how to replicate, and this is one of them.

I've always wondered how blogger uses javascript to ask "Are you sure you want to navigate away from this page? You have unsaved changes."

I was browsing around in some MSDN DOM documentation and found a window event called onbeforeunload. I've actually explored this issue once before and only got as far as onunload. Having the right keyword to put into google makes a real difference.

Add this javascript code to a page and then try to close the page.
window.onbeforeunload = confirmExit;
function confirmExit()
{
return "Are you sure you want to leave this page?";
}


source(s): http://msdn2.microsoft.com/en-us/library/ms536907.aspx, http://www.4guysfromrolla.com/demos/OnBeforeUnloadDemo1.htm