error C3861: 'sprintf_s': identifier not found

Poscik

Addon Developer
Addon Developer
Joined
Mar 28, 2008
Messages
512
Reaction score
3
Points
18
Location
Sulejówek
It's not the first time, when I have that problem. I wrote very simple mfd with secure functions, but I can't compile it. I hace that error which is in topic. Compiler is configured like in OrbiterWiki article. I tried to compile source on VC2005 and VC2008. In both I couldn't do that. Included headers:

#include "windows.h"
#include "orbitersdk.h"
#include "ssua.h"
#include "math.h"
#include "stdio.h"

What's wrong?
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,615
Reaction score
2,335
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
Hmm... maybe you have not updated the platform SDK since 2003?
 

Poscik

Addon Developer
Addon Developer
Joined
Mar 28, 2008
Messages
512
Reaction score
3
Points
18
Location
Sulejówek
Heh, no :) In 2003 I didn't know what is C++. If I remember, I have installed Platform SDK 2 years ago.
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,615
Reaction score
2,335
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
Then, you should have the functions in the standard C libraries... <cstdio> for example.
 

Poscik

Addon Developer
Addon Developer
Joined
Mar 28, 2008
Messages
512
Reaction score
3
Points
18
Location
Sulejówek
When I replace "stdio.h" to <cstdio>, I have the same effect :(
And If I have this problem, I can't compile CRT MFD too...
 

Bj

Addon Developer
Addon Developer
Donator
Joined
Oct 16, 2007
Messages
1,886
Reaction score
11
Points
0
Location
USA-WA
Website
www.orbiter-forum.com
Did you try compiling before you started your own MFD? Could it possibly be your code missing a ';' or something...
 

Poscik

Addon Developer
Addon Developer
Joined
Mar 28, 2008
Messages
512
Reaction score
3
Points
18
Location
Sulejówek
I made small experiment. I wrote program for command prompt, which is using sprintf_s. I included <stdio.h> and VC2008 built it with no errors and no warning. Very strange situation...
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,615
Reaction score
2,335
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
Yeah, looks like your settings lack an important system library maybe.
 

Poscik

Addon Developer
Addon Developer
Joined
Mar 28, 2008
Messages
512
Reaction score
3
Points
18
Location
Sulejówek
I tried to change a lot of options... no result.
Here is my configuration:
include.JPGlinkergeneral.JPGlinkerinput.JPG
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,615
Reaction score
2,335
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
And do you have any #defines missing in the beginning of the program? I think you need to define ORBITER_MODULE, but I doubt this causes your problem.
 

Poscik

Addon Developer
Addon Developer
Joined
Mar 28, 2008
Messages
512
Reaction score
3
Points
18
Location
Sulejówek
First few lines from CRT MFD:
Code:
#define STRICT
#define ORBITER_MODULE

#include "windows.h"
#include "orbitersdk.h"
#include "PanelR2.h"
#include "PanelC2.h"
#include "vc/MDU.h"
#include "vc/vc_defs.h"
#include "CRT.h"
#include "stdio.h"
#include "dps/IDP.h"
#include "dps/MasterTimingUnit.h"
...
 

Wraith

New member
Joined
Oct 7, 2008
Messages
59
Reaction score
0
Points
0
Location
Moscow
Poscik
Just replace sprintf_s with plain old sprintf and throw away the second argument (buffer size). Should work.
The warnings about 'deprecated function' can be either ignored, or suppressed via
Code:
#define _CRT_SECURE_NO_WARNINGS
before you include standard libraries. A more radical approach is to put this #define right into "crtdefs.h", that is included in every CRT header (that's what I did).
 

Poscik

Addon Developer
Addon Developer
Joined
Mar 28, 2008
Messages
512
Reaction score
3
Points
18
Location
Sulejówek
Thank you very much Wraith :) Everything is working :)
 
Top