Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile error ( error: 'vsprintf_s' was not declared in this scope ) #18

Open
Lintfy opened this issue Jun 30, 2018 · 4 comments
Open

Comments

@Lintfy
Copy link

Lintfy commented Jun 30, 2018

I tried to compile "controllgallery2.nim" , but ..

Error: execution of an external compiler program 'gcc.exe -c -w -mno-ms-bitfields -IC:\Users\(User name)\Documents\Language\Nim\nim-0.18.0\lib -o G:\Nim \nimcache\win_debug.cpp.obj C:\Users\(User name)\.nimble\pkgs\ui-0.9.2\ui\./libui/windows\debug.cpp' failed with exit code: 1 C:\Users\terur\.nimble\pkgs\ui-0.9.2\ui\./libui/windows\debug.cpp: In function 'void realbug(const char*, const char*, const char*, const char*, con st char*, va_list)': C:\Users\(User name)\.nimble\pkgs\ui-0.9.2\ui\./libui/windows\debug.cpp:76:31: error: 'vsprintf_s' was not declared in this scope vsprintf_s(msg, n, format, ap); ^

What I should do to fix that error?
(Sorry for my poor English..)

@haltcase
Copy link

haltcase commented Aug 20, 2018

Pretty sure this is an issue with libui:

andlabs/libui#259

@haltcase
Copy link

haltcase commented Aug 21, 2018

The root as I understand it is that vsprintf_s is a more secure version of the original vsprintf but it's a Microsoft extension only present in vcc, meaning it fails to compile with gcc/mingw. You can monkey patch this to fix it locally:

  1. Go wherever you have nimble installing your packages

    Windows default: C:\Users\<USER>\.nimble\pkgs
    Unix default: ~/.nimble/pkgs

  2. Go to ui-<version>\ui\libui\windows

  3. Open debug.cpp and comment out line 76:

    -vsprintf_s(msg, n, format, ap);
    +// vsprintf_s(msg, n, format, ap);

This will solve that error, but there are more of these in libui:

  • utf16.cpp:59 wcscpy_s
  • utf16.cpp:90 vswprintf_s

@kidandcat
Copy link

This is still happening, libui issue is closed as resolved: andlabs/libui#259

@haltcase
Copy link

haltcase commented Jul 5, 2019

@kidandcat it doesn't appear to be closed yet per the issue status and the latest comment from the dev. The safe string functions mentioned here will still likely cause these errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants