SDL-1.2.10 Win32 Build error: mmintrin.h

I get this error:

C:\Code\SDL-1.2.10\src\video\SDL_blit_A.c(42) : fatal error C1083: Cannot open
include file: ‘mmintrin.h’: No such file or directory

This appears to be because SDL_ASSEMBLY_ROUTINES is defined which causes SDL
to defined MSVC_ASMBLIT and then it tries to include:

/* Function to check the CPU flags */
#include “SDL_cpuinfo.h”
#if GCC_ASMBLIT
#include “mmx.h”
#elif MSVC_ASMBLIT
#include <mmintrin.h>
#include <mm3dnow.h>
#endif

Any ideas?

Ken Rogoway <Ken HomebrewSoftware.com> writes:

C:\Code\SDL-1.2.10\src\video\SDL_blit_A.c(42) : fatal error C1083: Cannot
open
include file: ‘mmintrin.h’: No such file or directory

This appears to be because SDL_ASSEMBLY_ROUTINES is defined which causes SDL
to defined MSVC_ASMBLIT and then it tries to include:

/* Function to check the CPU flags */
#include “SDL_cpuinfo.h”
#if GCC_ASMBLIT
#include “mmx.h”
#elif MSVC_ASMBLIT
#include <mmintrin.h>
#include <mm3dnow.h>
#endif

NOTE: This happens when using the Visual Studio 6 project provided.

ALSO: The Visual Studio .sln file is a 2005 (Version 9.00) solution. If you
have Visual Studio 7.0 or 7.1 then this will complain it is NOT a valid
solution. I would recommend have separate solutions for 7.x and 9.x

If I take the .dsw file (for Visual Studio 6.0) and use it with Visual Studio
7.0 to create a new solution, then when I build I have no problems. The
problem listed below appears to be with the setup/config for VC 6.0

Ken Rogoway wrote:

I get this error:
C:\Code\SDL-1.2.10\src\video\SDL_blit_A.c(42) : fatal error C1083: Cannot
open include file: ‘mmintrin.h’: No such file or directory

You need to have VC6 with Processor Pack installed (the pack is free), or
VC7 and above to build the MSVC MMX intrinsics code.

This appears to be because SDL_ASSEMBLY_ROUTINES is defined

You can disable the #define in include/SDL_config_win32.h if you have to.

-Alex.

Alex Volkov <avcp-sdlmail usa.net> writes:

Ken Rogoway wrote:

I get this error:
C:\Code\SDL-1.2.10\src\video\SDL_blit_A.c(42) : fatal error C1083: Cannot
open include file: ‘mmintrin.h’: No such file or directory

You need to have VC6 with Processor Pack installed (the pack is free), or
VC7 and above to build the MSVC MMX intrinsics code.

This appears to be because SDL_ASSEMBLY_ROUTINES is defined

You can disable the #define in include/SDL_config_win32.h if you have to.

-Alex.

Thanks Alex. I realize I can hack my version as a temporary workaround, but
this is the first time in a very long time that the distribution wasn’t
correct. Anyone else with VC6 is going to have the exact same problem and I
know Sam likes to fix these types of configuration issues so I reported it.

  • Ken

Ken Rogoway wrote:

Anyone else with VC6 is going to have the exact same problem
and I know Sam likes to fix these types of configuration issues
so I reported it.

Of course! I was not suggesting otherwise :wink:
Seeing how the introduction of that code was, in part, my fault, I should
propose a solution. However, I do not have a VC7+ version handy and cannot
check if VC7+ automatically #defines _MSC_FULL_VER. The conditional in
SDL_blit_A.c –
#elif defined(_MSC_VER) && (_MSC_VER >= 1200) && defined(_M_IX86)
should most likely use the _MSC_FULL_VER guard instead of _MSC_VER, since
the Processor Pack for VC6 already defines it. Something to the extent of –
#elif defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 12008800) &&
defined(_M_IX86)

-Alex.

Ken Rogoway wrote:

Anyone else with VC6 is going to have the exact same problem
and I know Sam likes to fix these types of configuration issues
so I reported it.

Of course! I was not suggesting otherwise :wink:
Seeing how the introduction of that code was, in part, my fault, I should
propose a solution. However, I do not have a VC7+ version handy and cannot
check if VC7+ automatically #defines _MSC_FULL_VER. The conditional in
SDL_blit_A.c –
#elif defined(_MSC_VER) && (_MSC_VER >= 1200) && defined(_M_IX86)
should most likely use the _MSC_FULL_VER guard instead of _MSC_VER, since
the Processor Pack for VC6 already defines it. Something to the extent of –
#elif defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 12008800) &&
defined(_M_IX86)

Is there any way to explicitly check for the processor pack? Maybe
some #define somewhere?

-Sam Lantinga, Senior Software Engineer, Blizzard Entertainment

Alex Volkov <avcp-sdlmail usa.net> writes:

Ken Rogoway wrote:

Anyone else with VC6 is going to have the exact same problem
and I know Sam likes to fix these types of configuration issues
so I reported it.

Of course! I was not suggesting otherwise :wink:
Seeing how the introduction of that code was, in part, my fault, I should
propose a solution. However, I do not have a VC7+ version handy and cannot
check if VC7+ automatically #defines _MSC_FULL_VER. The conditional in
SDL_blit_A.c –
#elif defined(_MSC_VER) && (_MSC_VER >= 1200) && defined(_M_IX86)
should most likely use the _MSC_FULL_VER guard instead of _MSC_VER, since
the Processor Pack for VC6 already defines it. Something to the extent of –
#elif defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 12008800) &&
defined(_M_IX86)

-Alex.

I have both VC6 and VC7. I changed the code in SDL_Blit_A.c to:

#elif defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 12008800) && defined(_M_IX86)

That still compiles the next 2 lines with VC6. So in VC6 both of these are
true:

// This is true in VC6
#elif defined(_MSC_VER) && (_MSC_VER >= 1200) && defined(_M_IX86)

// This is true in VC6
#elif defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 12008800) && defined(_M_IX86)

Sam Lantinga wrote:

Is there any way to explicitly check for the processor pack?
Maybe some #define somewhere?

There appears to be none. :-
The only difference between stock VC6 and +Processor Pack is in C2.DLL
(installed in VC98\Bin) and mmintrin.h/mm3dnow.h headers being present. The
MMX intrinsics support is present in the VC6 preprocessor since service pack
4 or so, but the code will not compile w/o updated C2.DLL. And the processor
pack does not bump the version reported by _MSC_VER and _MSC_FULL_VER,
like Ken Rogoway proved.
I originally posted my MSVC MMX patches with a new build configuration in
the project file (.dsp) – “Release ASMBLIT”, which #defined
SDL_ASSEMBLY_ROUTINES (or actually its equivalent at the time), in part
because I could not find a way to reliably detect Processor Pack without
resorting to things like ‘configure’.

-Alex.

Hello Ken,

Thursday, June 1, 2006, 5:30:38 AM, you wrote:

KR> ALSO: The Visual Studio .sln file is a 2005 (Version 9.00) solution. If you
KR> have Visual Studio 7.0 or 7.1 then this will complain it is NOT a valid
KR> solution. I would recommend have separate solutions for 7.x and 9.x

The stupid thing is, this is what XML is supposed to be for.

You can alter the Version key to 7.00 or 7.10 and it should read it
just fine.–
Best regards,
Peter mailto:@Peter_Mulholland

Sam Lantinga wrote:

Is there any way to explicitly check for the processor pack?
Maybe some #define somewhere?

Alex Volkov wrote:

There appears to be none.

Actually, I looked very hard, and there does appear to be a way. It’s a
hack, but the kind that should not get invalidated by future VC6 versions
(since VC6 is at almost the end of its life).
The guards should be something like this:

#elif defined(_MSC_VER) && (_MSC_VER >= 1200) && defined(_M_IX86)
/* Dirty hack – VC6 Processor Pack installs malloc.h that

  • defines _mm_malloc. Luckily, we only need this trick for VC6,
  • and it looks like VC6 will not change anymore */
    #include <malloc.h>
    #if (_MSC_VER >= 1300) || defined(_mm_malloc)
    #define MMX_ASMBLIT 1
    #define MSVC_ASMBLIT 1
    #endif
    #endif

Ken, please test this with your VC6 and VC7 versions if you can. Thank you!

-Alex.

Alex Volkov <avcp-sdlmail usa.net> writes:

Sam Lantinga wrote:

Is there any way to explicitly check for the processor pack?
Maybe some #define somewhere?

Alex Volkov wrote:

There appears to be none.

Actually, I looked very hard, and there does appear to be a way. It’s a
hack, but the kind that should not get invalidated by future VC6 versions
(since VC6 is at almost the end of its life).
The guards should be something like this:

#elif defined(_MSC_VER) && (_MSC_VER >= 1200) && defined(_M_IX86)
/* Dirty hack – VC6 Processor Pack installs malloc.h that

  • defines _mm_malloc. Luckily, we only need this trick for VC6,
  • and it looks like VC6 will not change anymore */
    #include <malloc.h>
    #if (_MSC_VER >= 1300) || defined(_mm_malloc)
    #define MMX_ASMBLIT 1
    #define MSVC_ASMBLIT 1
    #endif
    #endif

Ken, please test this with your VC6 and VC7 versions if you can. Thank you!

-Alex.

I tested it and it works for both VC6 and VC7. The actual block in
SDL_blit_A.c is:

#if SDL_ASSEMBLY_ROUTINES
#if defined(GNUC) && (defined(i386) || defined(x86_64))
#define MMX_ASMBLIT 1
#define GCC_ASMBLIT 1
#elif defined(_MSC_VER) && (_MSC_VER >= 1200) && defined(_M_IX86)
/* Dirty hack – VC6 Processor Pack installs malloc.h that

  • defines _mm_malloc. Luckily, we only need this trick for VC6,
  • and it looks like VC6 will not change anymore /
    #include <malloc.h>
    #if (_MSC_VER >= 1300) || defined(_mm_malloc)
    #define MMX_ASMBLIT 1
    #define MSVC_ASMBLIT 1
    #endif
    #endif
    #endif /
    SDL_ASSEMBLY_ROUTINES */

I have another issue when compiling dibaudio.c:

c:\code\sdl-1.2.10\src\audio\windib\sdl_dibaudio.c(101) : error C2146: syntax
error : missing ‘)’ before identifier 'dwInstance’
c:\code\sdl-1.2.10\src\audio\windib\sdl_dibaudio.c(101) : error
C2081: ‘DWORD_PTR’ : name in formal parameter list illegal

This is referring to:

/* The Win32 callback for filling the WAVE device */
static void CALLBACK FillSound(HWAVEOUT hwo, UINT uMsg, DWORD_PTR dwInstance,
DWORD dwParam1, DWORD dwParam2)
{

This only happens when compiling with VC6.

Ken Rogoway wrote:

I tested it and it works for both VC6 and VC7.

Thanks!

I have another issue when compiling dibaudio.c:
c:\code\sdl-1.2.10\src\audio\windib\sdl_dibaudio.c(101) : error C2146:
C2081: ‘DWORD_PTR’ : name in formal parameter list illegal

DWORD_PTR is used there for Win64 portability. Headers that ship with VC6 do
not define DWORD_PTR (probably because VC6 cannot do 64-bit builds). I am
not sure if the DirectX SDK does, but the Platform SDK definitely defines
it. I have Platform SDK installed, so I never noticed these myself.
That said, we can either define DWORD_PTR ourselves for win32, or rely on
Platform SDK and make this SDK a requirement, instead of DirectX SDK.

-Alex.

Alex Volkov <avcp-sdlmail usa.net> writes:

Ken Rogoway wrote:

I tested it and it works for both VC6 and VC7.

Thanks!

I have another issue when compiling dibaudio.c:
c:\code\sdl-1.2.10\src\audio\windib\sdl_dibaudio.c(101) : error C2146:
C2081: ‘DWORD_PTR’ : name in formal parameter list illegal

DWORD_PTR is used there for Win64 portability. Headers that ship with VC6 do
not define DWORD_PTR (probably because VC6 cannot do 64-bit builds). I am
not sure if the DirectX SDK does, but the Platform SDK definitely defines
it. I have Platform SDK installed, so I never noticed these myself.
That said, we can either define DWORD_PTR ourselves for win32, or rely on
Platform SDK and make this SDK a requirement, instead of DirectX SDK.

-Alex.

I am open to either. When you say the “platform SDK” what are you talking
about? I have DX9 SDK installed. I am willing to install the Platform SDK,
but am not familiar with it by that name.

  • K

Ken Rogoway wrote:

When you say the “platform SDK” what are you talking about?
I have DX9 SDK installed. I am willing to install the Platform SDK,
but am not familiar with it by that name.

It is Microsoft’s Platform SDK – http://msdn.microsoft.com/platformsdk/.
This SDK includes nearly all updated SDKs (without duplication of files) MS
releases, but not the DDKs. It is rather large (~400M), but comes with all
updated headers, libs, and even free 64-bit compilers.

-Alex.