inline function in visual c++ 6.0
I have some static bool inline function in the project (it's not my code):
static bool inline
is_safe_raw(CHAR_DATA *ch, CHAR_DATA *victim)
{
/*
* ghosts are safe
* this check must be done first to avoid
* suicyco who recite 'leather-bound book' (#5743)
* without any target specified
* extracted NPCs are safe too
*/
if (!IS_NPC(victim)) {
int clan;
/* ghost cannot attack anyone */
if (ch != victim
&& !IS_NPC(ch)
&& IS_SET(ch->plr_flags, PLR_GHOST))
return TRUE;
/* clan defenders can attack anyone in their clan */
if (victim->in_room
&& (clan = victim->in_room->area->clan)
&& victim->clan != clan
&& ch->clan == clan)
return FALSE;
/* otherwise ghosts are safe */
if (IS_SET(victim->plr_flags, PLR_GHOST开发者_如何学JAVA))
return TRUE;
}
else if (victim->extracted)
return TRUE;
if (victim->fighting == ch
|| ch == victim
|| IS_IMMORTAL(ch))
return FALSE;
/* handle ROOM_PEACE flags */
if ((victim->in_room && IS_SET(victim->in_room->room_flags, ROOM_PEACE))
|| (ch->in_room && IS_SET(ch->in_room->room_flags, ROOM_PEACE)))
return TRUE;
/* link dead players whose adrenalin is not gushing are safe */
if (!IS_NPC(victim) && !IS_PUMPED(victim) && victim->desc == NULL)
return TRUE;
return !in_PK(ch, victim);
}
I'm trying to compile (make) it using Visual C++ 6.0 NMake (the project is '98 year) and it throws this error:
Microsoft (R) Program Maintenance Utility Version 6.00.8168.0
Copyright (C) Microsoft Corp 1988-1998. All rights reserved.
cl.exe /nologo /ML /W3 /G4e /O2g /D "WIN32" /YX /c -I . -I ..\msgdb -I .
\COMM -I .\COMPAT -I .\DB -I .\OLC -I .\COMPAT\regex-win32 /Fofight.obj fight.c
Command line warning D4002 : ignoring unknown option '/Og'
fight.c
fight.c(1446) : error C2061: syntax error : identifier 'is_safe_raw'
fight.c(1446) : error C2059: syntax error : ';'
fight.c(1446) : error C2059: syntax error : 'type'
fight.c(1520) : warning C4013: 'is_safe_raw' undefined; assuming extern returnin
g int
NMAKE : fatal error U1077: 'cl.exe' : return code '0x2'
Stop.
If I get out "inline" modifier - it compiles well. But I can't understand why. Could somebody explain it to me?
Your source file has .c
extension, which means that by default it will be compiled as C language source file. The compiler you are using is implementing the C89/90 version of C language, which does not have such thing as inline
. Hence the error.
If this is supposed to be C++ code (and your question is tagged [C++]), you have to either give your file .cpp
extension or use a compiler switch that would force the compiler to treat the file as C++ code.
If this is supposed to be C code, then with this compiler your are restricted to C89/90, which has no inline
at all. The compiler might support some alternative keyword for function inlining as an extension. Could be _inline
or __inline
or something like that.
First of all, inline is delacred first, and second inline is only declared in header file. Hope that helps!
Perhaps someone has done a #define of inline to something unhelpful? You could try examining the preprocessor output (/E
, I think) to see exactly what the compiler is seeing.
Have you tried one of the other variants, such as "__inline"?
精彩评论