Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

254
Views
Agregar archivos de encabezado C en C ++ usando "C" externo Genera un error en el tipo 'estático'

Estaba trabajando en un compositor wayland basado en C++. Mi proyecto usa wlroots, que es una biblioteca C. Tengo un conjunto de archivos de encabezado en wlroots que necesito agregar a mi proyecto de C++. Utilicé "C" externo para incluir archivos de encabezado c pero mostraba errores en el tipo 'estático'.

 /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]); | ^~~~~~

Aquí está el código de muestra para referencia:

 #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

Investigué un poco y descubrí una manera de solucionarlo. por este método:

 #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

Pero no estoy seguro de si causará algún problema en el futuro. Esto parece ser un método de pirateo. ¿Hay algún método mejor para superar esto?

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!