Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

250
Vistas
Adding C header files in C++ using extern "C" Generates error on 'static' type

I was working on a wayland compositor based on C++. My project uses wlroots which is a C Library. I have a set of header files in wlroots which i need to add to my C++ project. I used extern "C" to include c header files but it was showing errors on 'static' type.

/usr/local/include/wlr/render/wlr_renderer.h:72:27: error: expected primary-expression before ‘static’
   72 |         const float color[static 4], const float projection[static 9]);
      |                           ^~~~~~

Here is the sample code for reference :

#ifndef SERVER_HPP
#define SERVER_HPP

#include <wayland-server.h>

extern "C"
{
    #include <wlr/backend.h>
    #include <wlr/render/allocator.h>
    #include <wlr/render/wlr_renderer.h>
    #include <wlr/types/wlr_compositor.h>
};


class Server
{
    public:
        struct wl_display *wl_display;
        struct wl_event_loop *wl_event_loop;

        struct wlr_backend *backend;
        struct wlr_renderer *renderer;
        struct wlr_allocator *allocator;
        struct wlr_compositor *compositor;

    public:
        bool init();
        bool run();
        void terminate();
};

#endif

I did some digging and find out a way to fix it. by this method:

#define static

extern "C"
{
    #include <wlr/backend.h>
    #include <wlr/render/allocator.h>
    #include <wlr/render/wlr_renderer.h>
    #include <wlr/types/wlr_compositor.h>
};

#undef static

But i am not sure whether it will cause any issues in the future. This seems to be a hack method. Is there any better method to overcome this?

over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda