![]() |
|
Works in Linux but doesn't in WindowsXP |
Niunio
Member #1,975
March 2002
![]() |
I've developed a small scripting interpretor to prove myself (it's very simple but may be useful). I've wrote it in ANSY-C in GNU/Linux and it runs the test scripts perfectly. The simplest script is a "Hello, world!" and the most complex is a "Guess the number" game. If there's an error in the script, the interpretor throws its state in a text file (stacks, variables, execution point, etc.). The problem comes when I try to run it in WindowsXP. It compiles the interpretor without errors nor warnings (I'm using the "-Wall" flag) but it has a very strange behavior:
The interpretor is simple, but all internals and documentation are written in Spanish. I've tried to isolate the problem, but when I run the modules separately it seems to run perfectly, and I can't isolate the interpretor itself. I've attached the latest "stable but under development" version of the project, but remember: all the documentation and internals are written in Spanish. I'm using MinGW32 3.4.2 and MSys 1.0.11. Anybody else wrote an ANSI/POSIX C program that runs in GNU/Linux but doesn't in Windows? Does anyone knows why? Does anyone knows how to fix it? ----------------- |
Evert
Member #794
November 2000
![]() |
Could this have to do with line endings? Disclaimer: I haven't looked at your source, so this may not be related to your problem in any way. |
Niunio
Member #1,975
March 2002
![]() |
Evert said: Be sure to open text files with "rt" and write them as "wt" in Windows, otherwise things will break. I did it, using "rb", "at" and "wt" and all the scripts are in DOS format and still not working. Another thing: I'm using "stderr" to show the error messages. May be Windows override "stderr" and then I can't see the error messages [edit]I've changed all "stderr" by "stdout" and everything is the same... ----------------- |
umperio
Member #3,474
April 2003
![]() |
You could use freopen and redirect stderr to a text file. |
Niunio
Member #1,975
March 2002
![]() |
OMG! I've changed the "rb" by "rt" and it said there's an error loading the scripts that doesn't work! But I see the code is right, doesn't it? I've translated the comments to english:
Curiously there's a script that is loaded and run perfectly [edit]I think there's a problem with the way I calculate the size of the file... When I use "rb" it gets the correct size, when I use "rt" it doesn't. ----------------- |
ReyBrujo
Moderator
January 2001
![]() |
Remember that the formats are different. Where did you create the script, linux or windows? -- |
Niunio
Member #1,975
March 2002
![]() |
I did created them in Linux, but I want to make it cross platform. That's was I used "rb" to load the scripts. The interpretor just skip the '\n' and '\r' characters as spaces. [edit]That's really strange: I've added this line [edit2] Forget it: after reboot Windows the magic disappears... ----------------- |
|