Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

251
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda