# C++ define etc.

## Recommended Posts

HI

I try to compile some code and get "expected { in VC Community edition at line:

static void setup_texture_filter(GLuint tex, GLint miplevels, GLint int_fmt,
GLsizei width, GLsizei height, GLenum format, GLenum type,
const GLvoid* data, GLint mag_filter, GLint min_filter) UNUSED_ATTR;

#define    UNUSED_ATTR    __attribute__((unused))
#define    UNUSED(x)    (void)(x)

I don't understand those define and all code. Many thanks

##### Share on other sites

The  #define is just used as a text replacement. So everywhere UNUSED_ATTR occurs, it is replaced by __attribute__((unused))﻿﻿ before the compiler starts working. This is usually done to add compiler or system dependent code.

__attribute__((unused)) itself just suppresses a compiler warning that this function was never used:

From the compiler error, I would guess, that the semicolon is somehow not recognized. Try moving the semicolon to the next line or just place a space between the macro and the semicolon.

Greetings

##### Share on other sites

I could be wrong but isn't

__attribute__

a GCC compiler token and not MSVC?

##### Share on other sites
Posted (edited)

Yes seems so. Now I have in cpp:

librain_draw_prepare(FALSE);

and get error:

LIBRAIN_EXPORT void librain_draw_prepare_all(void);

also in cpp:

static mat4 glob_proj_matrix = GLM_MAT4_IDENTITY;

i get error:

vec4 cannot be used to initialise typ float

#define GLM_MAT4_IDENTITY ((mat4)GLM_MAT4_IDENTITY_INIT)

Could I use mingw in VS community edition? Many thanks for help.

Edited by ePitts

##### Share on other sites
2 hours ago, Shaarigan said:

I could be wrong but isn't


__attribute__

a GCC compiler token and not MSVC?

That's probably why the #define UNUSED_ATTR is used in the first place. I would guess, that there is somewhere in the code an #ifdef MSVC block which defines it to be empty and the TS just posted the version he found first (in this case the GCC version).

Additional Info: Since C++17 there is a standard attribute to silence "unused" warnings: [[maybe_unused]]. This should work for any compiler but isn't backward compatible.

@TS:

Which library/code are you trying to compile? Maybe there is a documentation about supported compilers/systems and known issues.

2 hours ago, ePitts said:

Could I use mingw in VS community edition? Many thanks for help.

I can't answer this question, but from the general Microsoft policy, I would guess that there is no initial support. Maybe some plugins that do that are available.

Here is a stackoverflow link related to this question:

Greetings

##### Share on other sites

*shudder*

A hairy piece of code with all those defines ... who knows where they are defined, in the code, the environment, passed in as compiler options ... coming from elsewhere.

The #define glm_mat4_identity seems nonsensical to me, the glm::mat4() default constructor returns an indentity matrix ...

##### Share on other sites

So to get this clerified, you definitely have a problem with the preprocessor. To solve this you should either download a fress version and follow the instructions or dig through the code and find some configuration header to see where the problem comes from. I know Visual Studio 2017 is capable of detecting via Intellisense where a certain macro was defined in the code so maybe you are walking the path back until you find the broken line

## Create an account

Register a new account

• 18
• 26
• 11
• 21
• 16