We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1879 - Problem with /SUBSYSTEM:WINDOWS and SDLmain.lib
Summary: Problem with /SUBSYSTEM:WINDOWS and SDLmain.lib
Status: RESOLVED ENDOFLIFE
Alias: None
Product: SDL
Classification: Unclassified
Component: main (show other bugs)
Version: 1.2.15
Hardware: x86 Windows 7
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-30 14:49 UTC by briggs_w
Modified: 2015-08-25 09:38 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description briggs_w 2013-05-30 14:49:55 UTC
Switching the Subsystem from /SUBSYSTEM:CONSOLE to /SUBSYSTEM:WINDOWS (per http://forums.libsdl.org/viewtopic.php?t=3553&highlight=console ) does make the console window not show up, but it causes a crash in SDL_Win32_main.c's int console_main(int argc, char *argv[]); .  The problem is that the function assumes argv is a valid array of char*'s, and tries to access it; but argv is the NULL pointer.

This can be repaired with an if statement; see below.  I have verified that it works with /SUBSYSTEM:CONSOLE and with /SUBSYSTEM:WINDOWS, but there may be something else I'm not thinking of.


int console_main(int argc, char *argv[])
{
	size_t n;
	char *bufp, *appname;
	int status;

	if (argc) //THIS if STATEMENT IS THE BUG FIX IN QUESTION
	{
		/* Get the class name from argv[0] */
		appname = argv[0];
		if ( (bufp=SDL_strrchr(argv[0], '\\')) != NULL ) {
			appname = bufp+1;
		} else
		if ( (bufp=SDL_strrchr(argv[0], '/')) != NULL ) {
			appname = bufp+1;
		}

		if ( (bufp=SDL_strrchr(appname, '.')) == NULL )
			n = SDL_strlen(appname);
		else
			n = (bufp-appname);

		bufp = SDL_stack_alloc(char, n+1);
		if ( bufp == NULL ) {
			return OutOfMemory();
		}
		SDL_strlcpy(bufp, appname, n+1);
		appname = bufp;
	}

	/* Load SDL dynamic link library */

        ...and so on...
}
Comment 1 Ryan C. Gordon 2015-08-25 09:38:23 UTC
Hello, and sorry if you're getting several copies of this message by email, since we are closing many bugs at once here.

We have decided to mark all SDL 1.2-related bugs as RESOLVED ENDOFLIFE, as we don't intend to work on SDL 1.2 any further, but didn't want to mark a large quantity of bugs as RESOLVED WONTFIX, to clearly show what was left unattended to and make it easily searchable.

Our current focus is on SDL 2.0.

If you are still having problems with an ENDOFLIFE bug, your absolute best option is to move your program to SDL2, as it will likely fix the problem by default, and give you access to modern platforms and tons of super-cool new features.

Failing that, we _will_ accept small patches to fix these issues, and put them in revision control, although we do not intend to do any further official 1.2 releases.

Failing that, please feel free to contact me directly by email (icculus@icculus.org) and we'll try to find some way to help you out of your situation.

Thank you,
--ryan.