Development > Newbie Coding

new makro

(1/4) > >>

Muton:
I tried to add a new macro
to also show the svn revision on the ufoai mainscreen (prevent posts "I dont know the revision of my build")

First i used int and all worked fine
The number was shown
but than i tried to add a string to add rev29954
C::B now returns always a warning (the exe crash)
common.c:887:60: warning: character constant too long for its type
common.c: In function 'Qcommon_Init':
common.c:887: warning: format '%s' expects type 'char *', but argument 3 has type 'int'

After h's of trial and error i tried a small piece of code

--- Code: ---#include <stdio.h>

#  ifdef REVISION
#    define UFO_REVISION REVISION
#  else
#    define UFO_REVISION ""
#  endif

void main(void) {
printf("%s\n", UFO_REVISION);
}

--- End code ---

To compile i've used first MinGW environment
mingw32-gcc.exe -DREVISION='"rev1234"' test.c -otest.exe
the output was than as expected
but if i run the same on cmd.exe
test.c:10:17: warning: character constant too long for its type
C::B does use the correct command-line

The question now is whats the problem ???
The code can't be?!

I've used this manual (bottom) http://www.network-theory.co.uk/docs/gccintro/gccintro_35.html
-DMACRONAME='"stringvalue"'




I`'ve added

--- Code: (common.h) ---#define UFO_VERSION "2.3-dev"
#  ifdef REVISION
#    define UFO_REVISION REVISION
#  else
#    define UFO_REVISION ""
#  endif

--- End code ---


--- Code: (common.c) --- s = va("UFO: Alien Invasion %s %s %s %s %s", UFO_VERSION, UFO_REVISION, CPUSTRING, __DATE__, BUILDSTRING);

--- End code ---


--- Code: (ufo.cbp and ufo_ded.cbp) ---<Add option="-DREVISION='&quot;rev22568&quot;'" />

--- End code ---

Mattn:
the revision should only be the number - if you want to convert the number into a string, use the STRINGIFY macro

Mattn:
but - this is really nothing i would like to see solved like this. it must work crossplattform if this gets ever into svn. and that is not an easy task to do it for all the *nixes out there.

Duke:
If we boil it down to the minimum required, it should work cross-platform imho. Like:

--- Code: ---char verString[222];
int rev = 12345;
sprintf(verString, "UFO:AI V2.3 dev revision: %i\n", rev);
printf(verString);
--- End code ---

My biggest question is: how do you get the svn rev number into the call of mingW ??

Mattn:
maybe mingw also has the command svnversion - otherwise

--- Code: ---SVN_REV=$(shell LANG=C svn info | awk '$$1 == "Revision:" {print $$2; exit 0}')

--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version