0

Question: where do I get and how do I make strsafe.h work with Tiny C Compiler by Bellard.

Here is my Journey with MinGW header files, which is unsuccessful,
as I was unable to make strsafe.h headers of MinGW work with Tiny C Compiler.

The beginnings.

I wanted to run/compile some text-editor project written in C and
suddenly strsafe.h header was missing in the Tiny C Compiler \include folder.

jittey-main>tcc -run main.c
main.c:4: error: include file 'strsafe.h' not found

strsafe.h header seems to not be included in the Tiny C Compiler.
So I tried to download strsafe.h header from mingw project (strsafe.h)
I placed it into the /include folder and suddenly another missing header file poped up.

tcc -run main.c
In file included from main.c:4:
other/strsafe.h:9: error: include file '_mingw_unicode.h' not found

Alright, I tried to find _mingw_unicode.h in the mingw project.
And here I found it: mingw project (_mingw_unicode.h)
I placed it into /include folder just like before.

tcc -run main.c
In file included from main.c:4:
other/strsafe.h:13: error: include file 'specstrings.h' not found

Once again I was welcomed with another missing header file.
Here it is: mingw project (specstrings.h)
I placed it into /include folder just like before.

tcc -run main.c
In file included from main.c:4:
In file included from other/strsafe.h:13:
other/specstrings.h:12: error: include file 'sal.h' not found

Now this is getting repetitive... Alright It's here.
mingw project (strsafe.h)
I placed it into /include folder just like before.

Last one to resolve? I hope so.

tcc -run main.c
In file included from main.c:4:
In file included from other/strsafe.h:13:
other/specstrings.h:336: error: include file 'driverspecs.h' not found

Here it is: mingw project (driverspecs.h)
I placed it into /include folder just like before.

Slight change in errors. strsafe.h header contains C++ syntax? I'm stuck here.

From this error I guess that strsafe.h header from the MinGW project is not compatible with C89 C99 or C11 languages.

tcc -run main.c
In file included from main.c:4:
other/strsafe.h:131: error: ',' expected (got "dwFlags")

The exact error line can be found here: strsafe.h:131: error

I don't know what to do now.

user3789797
  • 450
  • 6
  • 15
  • 2
    "I placed it into the /include folder..." You seem to be lacking some basic understanding of what a header actually is. Headers only provide declarations for some types, variables and functions. They do not provide any implementation for them. A header is not a library. Just dropping a header into your folder will not work. You need to get the library or source package that provides the whole functionality. All required headers and especially the implementation for it. You need to search for the library that comes with that header and install that library.Or rewrite the code to use another lib – Gerhardh Jul 28 '21 at 07:41
  • 1
    From [this](https://learn.microsoft.com/en-us/windows/win32/menurc/strsafe-ovw) it seems that this should be part of some WIN32SDK which you probably need to install. – Gerhardh Jul 28 '21 at 07:49
  • 3
    "So I tried to download strsafe.h header from mingw project (strsafe.h)" - this is a dead end strategy . An implementation header depends on other implementation headers, you can't mix and match – M.M Jul 29 '21 at 06:40

1 Answers1

0

This is incomplete answer.
Does not answer how to setup TCC with windows-10-sdk.

Location of strsafe.h

I did some research and I've found that strsafe.h is part of windows-10-sdk

The setup file of windows-10-sdk is named winsdksetup.exe
The setup size is unexpectedly small. (1,29 MB)
However, the setup downloads and produces additional (1,86 GB) after installation.

windows-10-sdk gets installed into this directory by default:
C:\Program Files (x86)\Windows Kits\10

After installation of windows-10-sdk

The location of strsafe.h is here:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared\strsafe.h

The strsafe.lib file can be found here:

C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\um\x86\strsafe.lib
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\um\x64\strsafe.lib
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\um\arm64\strsafe.lib
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\um\arm\strsafe.lib

10.0.19041.0 is a version number of windows-10-sdk.

x86 x64 arm64 arm are the instruction set architectures.

Some additional required .h headers can be found here

C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\


Further failure to compile using Windows SDK

I had some trials to compile the previously mentioned text-editor project.

I found some instructions regarding compiling the project
with other compilers rather than Tiny C Compiler

I tried Linking the include .h headers of Windows SDK

tcc main.c "-IC:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared"

But it still came out as a failure.
I received the following errors:

jittey-main>tcc main.c "-IC:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared" "-LC:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\um\x86"
In file included from main.c:4:
In file included from c:/users/juozas/desktop/latest-built/include/winapi/windows.h:66:
In file included from C:/Program Files (x86)/Windows Kits/10/Include/10.0.19041.0/shared/windef.h:1:
C:/Program Files (x86)/Windows Kits/10/Include/10.0.19041.0/shared/winapifamily.h:226: warning: WINAPI_FAMILY_PARTITION redefined
In file included from main.c:4:
In file included from c:/users/juozas/desktop/latest-built/include/winapi/windows.h:67:
c:/users/juozas/desktop/latest-built/include/winapi/winbase.h:150: error: ';' expected (got "WINBOOL")

I suspect this error might be showing that the windows.h that already exists in Tiny C Compiler and is incompatible with the headers of Windows SDK.

I think Tiny C Compiler requires modified headers of Windows SDK, that could merge well.

Back to MinGW

After installation of Windows SDK and linking the .lib files.

As the same headers problems still occur and persist.

I think setting up TCC with MinGW might be worth a try.

One more suggestion is to re-compile Tiny C Compiler with MinGW headers.
But I'm not sure about that, not sure if it would do anything.
But I might try at some less busy day.
Compiling a file with TCC on windows with a library from C99

user3789797
  • 450
  • 6
  • 15