Jump to content
Eternal Lands Official Forums
Sign in to follow this  
Strings

IS_COLOR

Recommended Posts

Currently the IS_COLOR macro expects an unsigned_char which is unusual for character functions which normally take a char.

 

Now having checked the code every call to IS_COLOR is currently typed, but surely it's a bug waiting to happen.

 

I recommend that the macro is changed from

#define IS_COLOR(c ) ((c ) >= 127 + c_lbound && (c ) <= 127 + c_ubound)

to

#define IS_COLOR(c ) ((unsigned char)(c ) >= (127 + c_lbound) && (unsigned char)(c ) <= (127 + c_ubound))

 

this lack of type casting is one of the reasons that inline functions were created (to allow for parameter type checking).

 

 

 

And while I am on the subject of function inlining, is there any chance that we could have a fix to

get_items_texture()

could we either have the inline removed or could we have an #ifdef both in the function declaration and implementation.

 

#ifdef _MSVC_VER

GLuint get_items_texture(int no)

#else

__inline__ GLuint get_items_texture(int no)

#endif

 

 

 

And finally (for this message anyways)

loading_texture is defined as an int in loading_win.h and as a GLuint in the c file.

Could we change the header file to say

 

extern GLuint loading_texture;

Edited by Strings

Share this post


Link to post
Share on other sites

 

And while I am on the subject of function inlining, is there any chance that we could have a fix to

get_items_texture()

could we either have the inline removed or could we have an #ifdef both in the function declaration and implementation.

 

#ifdef _MSVC_VER

GLuint get_items_texture(int no)

#else

__inline__ GLuint get_items_texture(int no)

#endif

 

Using MSVC, I defined in global.h the line #define __inline__ __inline and no modifications in items.c.

Share this post


Link to post
Share on other sites

 

And while I am on the subject of function inlining, is there any chance that we could have a fix to

get_items_texture()

could we either have the inline removed or could we have an #ifdef both in the function declaration and implementation.

 

#ifdef _MSVC_VER

GLuint get_items_texture(int no)

#else

__inline__ GLuint get_items_texture(int no)

#endif

 

Using MSVC, I defined in global.h the line #define __inline__ __inline and no modifications in items.c.

 

Umm, that shouldn't work (see bottom of http://www.eternal-lands.com/forum/index.p...howtopic=19788)

How have you got the inlining options enabled in the compiler settings tab?

Share this post


Link to post
Share on other sites

http://msdn.microsoft.com/library/default....tml/lnk2001.asp

clearly states in bullet point 2, that inline functions should not appear in the c/cpp file.

 

The only reason that I could understand that Lhibou is working is either

a. He is actually commpiling the debug version which doesn't do any inlining

b. He is running the very latest version of MSVC (which I am not) and MS have finally sorted it out

 

Either way, I still recommend that inline is removed from any function in a c/cpp file as this is a compiler recommendation. It may not be a good compiler implementation but that's the downside of cross compile source.

 

Strings.

Edited by Strings

Share this post


Link to post
Share on other sites

hang on, isnt the only compiler we have to code for gnu gcc? and c99 spec yeah?

I thought that was the offical development platform, and codeing standard.

Does it have the same policys on in-lineing?

Share this post


Link to post
Share on other sites

GCC lets you declare functions as inline in .c-files but they can only be used as inline functions in that file. If you call it from other files it will not be inlined, hence all inlines should be in .h-files. In this case, just remove the __inline__ and make it a normal func.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×