Click here to Skip to main content
15,885,244 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Question#define VERSION 1.0.0 - too many decimal points Pin
Vaclav_16-Oct-14 4:12
Vaclav_16-Oct-14 4:12 
AnswerRe: #define VERSION 1.0.0 - too many decimal points Pin
Stefan_Lang16-Oct-14 4:35
Stefan_Lang16-Oct-14 4:35 
GeneralRe: #define VERSION 1.0.0 - too many decimal points Pin
PIEBALDconsult16-Oct-14 7:59
mvePIEBALDconsult16-Oct-14 7:59 
GeneralRe: #define VERSION 1.0.0 - too many decimal points Pin
CPallini16-Oct-14 9:17
mveCPallini16-Oct-14 9:17 
GeneralRe: #define VERSION 1.0.0 - too many decimal points Pin
PIEBALDconsult16-Oct-14 9:22
mvePIEBALDconsult16-Oct-14 9:22 
GeneralRe: #define VERSION 1.0.0 - too many decimal points Pin
CPallini16-Oct-14 9:45
mveCPallini16-Oct-14 9:45 
GeneralRe: #define VERSION 1.0.0 - too many decimal points Pin
Stefan_Lang17-Oct-14 3:08
Stefan_Lang17-Oct-14 3:08 
AnswerRe: #define VERSION 1.0.0 - too many decimal points Pin
PIEBALDconsult16-Oct-14 4:58
mvePIEBALDconsult16-Oct-14 4:58 
The problem is not with the defined value, but in how you are trying to use it. It will be difficult to use that value unless you make it a string, though you can stringize it. The following shows how it can be done (I used Borland's C/C++):

C
# include <stdio.h>
# define X(x) Y(x)
# define Y(y) #y

#define VERSION 1.0.0

void main() { printf ( "%s" , X ( VERSION ) ) ; }



http://msdn.microsoft.com/en-us/library/7e3a913x.aspx[^]


In general, if you use DEFINEs for constants (and you shouldn't), only use values that are valid literals.


Vaclav_Sal wrote:
What is the correct name for "the stuff"


MSDN calls it "token-string".

Syntax
#define identifier token-stringopt
#define identifier( identifieropt, ... , identifieropt ) token-stringopt

http://msdn.microsoft.com/en-us/library/teas0593.aspx[^]

modified 16-Oct-14 15:20pm.

GeneralRe: #define VERSION 1.0.0 - too many decimal points Pin
Vaclav_16-Oct-14 6:17
Vaclav_16-Oct-14 6:17 
GeneralRe: #define VERSION 1.0.0 - too many decimal points Pin
PIEBALDconsult16-Oct-14 7:27
mvePIEBALDconsult16-Oct-14 7:27 
GeneralRe: #define VERSION 1.0.0 - too many decimal points Pin
Albert Holguin16-Oct-14 12:33
professionalAlbert Holguin16-Oct-14 12:33 
GeneralRe: #define VERSION 1.0.0 - too many decimal points Pin
CPallini16-Oct-14 9:14
mveCPallini16-Oct-14 9:14 
AnswerRe: #define VERSION 1.0.0 - too many decimal points Pin
Richard MacCutchan16-Oct-14 6:27
mveRichard MacCutchan16-Oct-14 6:27 
GeneralRe: #define VERSION 1.0.0 - too many decimal points Pin
PIEBALDconsult16-Oct-14 7:29
mvePIEBALDconsult16-Oct-14 7:29 
GeneralRe: #define VERSION 1.0.0 - too many decimal points Pin
Richard MacCutchan16-Oct-14 22:14
mveRichard MacCutchan16-Oct-14 22:14 
GeneralRe: #define VERSION 1.0.0 - too many decimal points Pin
PIEBALDconsult17-Oct-14 5:03
mvePIEBALDconsult17-Oct-14 5:03 
GeneralSOLVED Re: #define VERSION 1.0.0 - too many decimal points Pin
Vaclav_16-Oct-14 7:32
Vaclav_16-Oct-14 7:32 
Questionwhich tool can be used develop c++ code i.e visual studio or unix Pin
Member 1112317113-Oct-14 9:30
Member 1112317113-Oct-14 9:30 
AnswerRe: which tool can be used develop c++ code i.e visual studio or unix Pin
Richard MacCutchan13-Oct-14 21:10
mveRichard MacCutchan13-Oct-14 21:10 
AnswerRe: which tool can be used develop c++ code i.e visual studio or unix Pin
CPallini13-Oct-14 22:08
mveCPallini13-Oct-14 22:08 
GeneralSuggestion on C++ Pin
Member 1081309011-Oct-14 4:45
Member 1081309011-Oct-14 4:45 
GeneralRe: Suggestion on C++ Pin
Michael Haephrati11-Oct-14 5:33
professionalMichael Haephrati11-Oct-14 5:33 
GeneralRe: Suggestion on C++ Pin
Member 1081309011-Oct-14 6:15
Member 1081309011-Oct-14 6:15 
GeneralRe: Suggestion on C++ Pin
Michael Haephrati11-Oct-14 7:11
professionalMichael Haephrati11-Oct-14 7:11 
GeneralRe: Suggestion on C++ Pin
jschell14-Oct-14 10:54
jschell14-Oct-14 10:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.