. /../Things that're different in.../ 1
sun + black hole = fwoosh!
written by Shadowlord on Aug 16, 2003 23:19
As opposed to for windows.

I'm just going to mention the things in the first program that I have made compile on both windows and linux.

First, windows.h and io.h don't exist. I expected windows.h to not exist, but io.h? Oh well.

The stuff I needed from those, didn't exist in linux either. I had to deal with them differently. To import the replacements, I had to include sys/types.h, dirent.h, and stdlib.h.

There is no MessageBox function in Linux. Since this program is console-mode anyhow, I replaced it like so:
#ifndef WINDOWS
	#define MB_OK 0
	void MessageBox(char *a, char *str, char *title, int b) {
		printf("%s\n",str);
	}

#endif
_finddata_t, _findfirst, and _findnext don't exist in linux. I used those to find all files in the current folder which matched the pattern "*.89t." In linux, the easiest way I found was to use opendir, readdir, and closedir, and use strrchar and strcasecmp to compare the extension to "89t" without case-sensitivity.

That's another thing, strcmpi doesn't exist in windows, but strcasecmp does the exact same thing in the exact same way.

To see if a folder existed:
#ifdef WINDOWS
	if( (hFile = _findfirst( folderName, &file )) == -1L ) {
#else
	DIR *dirdata=opendir(folderName);
	if (dirdata!=NULL) {
		closedir(dirdata);
	} else {
#endif
To handle directory paths:
#ifdef WINDOWS
	strcpy(tempString+strlen(tempString),"\\");
#else
	strcpy(tempString+strlen(tempString),"/");
#endif
And the routine that finds all .89t files and runs a function on each grew about doubled in size for linux, since I had to do the extension comparison myself.

However... There's one more difference.

The compiled linux program is 14.7 KB, whereas the Windows EXE is a whopping 62.5 KB! (I blame windows.h)

Edit: Find file routine:

└> last changed by Shadowlord on August 16, 2003 at 23:35
reading this thread
no members are reading this thread
. /../Things that're different in.../ 1
14748, 12 queries, 0.040 s.this frame is part of the AnyNowhere network