Jump to content

  • Log In with Google      Sign In   
  • Create Account


RobotGuy

Member Since 12 Aug 2008
Offline Last Active Feb 06 2013 04:12 PM
-----

Posts I've Made

In Topic: Trouble interpreting a custom language.

18 December 2012 - 04:55 PM

Quick thread hijack here. Any recommendations on free online resources on the subject of writing compilers and interpreters while we're at it? I can write CPU/bytecode interpreters (although I have never looked at stack based, only register based) but nothing more.


The best I ever came across (and I did manager to write a compiler based on this) is the Let's Build a Compiler series. It's complicated a bit by it being written in Pascal and generates executable code for 68000 processers, but it is relatively easy to follow and convert into C code and make it generate byte code.

In Topic: mysql connect

06 November 2010 - 11:17 AM

I must admit I'm beginning to run out of ideas, are you sure that mysql has networking enabled?

As you said that the command line tool connected, try:

mysql.exe --user=root --password= --host=localhost --protocol=TCP abelcorver_com



This will try to connect via network sockets and if it fails when it worked without the host and protocol parameters then I'd have to be pretty sure that mysql isn't listening on the network.

If so then you're going to have to alter your my.cnf to allow networking (check the mysql manual and make sure that skip-networking isn't included) or connect some other way. See if mysql is listening on a named pipe with:

mysql.exe --user=root --password= --protocol=PIPE abelcorver_com



If that works then either (and I have no experience with this as I use Unix) use "." instead of "localhost" in the call to mysql_real_connect or call mysql_options with MYSQL_OPT_NAMED_PIPE before the connect call.

If none of this works then I'm afraid I'm out of ideas. Does XAMPP have a forum? They would probably have a better idea about the default configuration of mysql that is used.

In Topic: mysql connect

29 October 2010 - 07:49 AM

Shouldn't be a version mismatch as as far as I know both the server and client libraries are all backwardly compatible and I believe negotiate an appropriate protocol version between themselves. At least, I've never had to change the library I link against when changing the server version. I suppose if the versions where really far apart there could be a problem but you'd really have to work at it.

As a suggestion, try changing the host parameter ("localhost") to your real IP address (i.e. not 127.0.0.1) and see if it works (or at least gives a different error message). If so then it is some issue with the library attempting to talk via the unix socket and it isn't working.

Out of interest, can you connect with the mysql.exe program?


cd C:/xampp/mysql/bin
mysql.exe --user=root --password= abelcorver_com




In Topic: mysql connect

27 October 2010 - 09:03 AM

I can't guarantee that this is you issue because I haven't done a great deal of work with mysql on windows but under unix, mysql is really good at automatically assuming that if you are connecting to localhost then it should use the unix socket. If you really want to use TCP then you have to tell it before hand.

Either check that you can connect via the unix type socket "C:/xampp/mysql/mysql.sock" or call mysql_options() with MYSQL_OPT_PROTOCOL and set the protocol to MYSQL_PROTOCOL_TCP before you call mysql_real_connect().

In Topic: [C++] Reading random line in big file

19 September 2010 - 09:10 AM

Quote:
Original post by Gage64
I meant you should generate a random number, use it as an argument to ifstream::seekg(), and then read one character at a time until you read a newline (that is, a '\n'). After this you know you're at the beginning of a line, and you can get the offset using tellg().


This will mostly work but there is a small issue in that, as written, the first line will never be picked and there is an issue when the random offset is in the last line. You must either search backwards for the newline (best done be reading a block of data, all at once, before the offset and scanning backwards through memory and repeating this if the newline or beginning of the file isn't found) or if you find the end of the file before a newline or the newline is the last character in the file wrap around to the beginning to get the first line.

In addition, be aware that it will only give a equal chance to each line if the lines are of the same length. If all the lines except one are of length N and the remaining one is of length 2N, the line after this one will have twice the chance of being picked. This might be fine for your purposes but you should bear this in mind.

PARTNERS