Coder Social home page Coder Social logo

edo9300 / irrlicht1-8-4 Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 1.0 51.62 MB

Fork of the irrlicht engine

License: Other

C++ 54.25% C 38.06% Objective-C 0.07% Objective-C++ 0.72% Makefile 0.59% Python 0.55% XSLT 0.08% Shell 2.29% Roff 2.26% CSS 0.01% Perl 0.04% M4 0.08% SAS 0.09% Smalltalk 0.04% WebAssembly 0.09% Assembly 0.06% Module Management System 0.09% CMake 0.29% StringTemplate 0.03% GLSL 0.32%

irrlicht1-8-4's People

Contributors

edo9300 avatar sagehane avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

sagehane

irrlicht1-8-4's Issues

Remove pointer arithmetic on void pointers

As is, this project fails to compile on Clang (and presumably any non-GCC compiler).

This is because wl_array_for_each performs pointer arithmetic on void pointers, which is illegal on ISO C/C++.[0] GCC allows this as an extension.[1]

-Werror=pointer-arith should probably be passed to spot such things in the future, if possible.


Compiling on Clang:

CIrrDeviceWayland.cpp:857:9: error: arithmetic on a pointer to void
        wl_array_for_each(state_p, states) {
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/nix/store/01rcndpymayvrpswqx34znwfxx82bwvd-wayland-1.20.0-dev/include/wayland-util.h:594:12: note: expanded from macro 'wl_array_for_each'
             (pos)++)
             ~~~~~^
CIrrDeviceWayland.cpp:922:9: error: arithmetic on a pointer to void
        wl_array_for_each(state_p, states) {
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/nix/store/01rcndpymayvrpswqx34znwfxx82bwvd-wayland-1.20.0-dev/include/wayland-util.h:594:12: note: expanded from macro 'wl_array_for_each'
             (pos)++)
             ~~~~~^

Compiling on GCC with -Werror=pointer-arith:

CIrrDeviceWayland.cpp: In static member function ‘static void irr::WaylandCallbacks::xdg_toplevel_configure(void*, xdg_toplevel*, int32_t, int32_t, wl_array*)’:
CIrrDeviceWayland.cpp:857:27: error: ISO C++ forbids incrementing a pointer of type ‘void*’ [-Werror=pointer-arith]
  857 |         wl_array_for_each(state_p, states) {
      |                           ^
CIrrDeviceWayland.cpp: In static member function ‘static void irr::WaylandCallbacks::zxdg_toplevel_configure(void*, zxdg_toplevel_v6*, int32_t, int32_t, wl_array*)’:
CIrrDeviceWayland.cpp:922:27: error: ISO C++ forbids incrementing a pointer of type ‘void*’ [-Werror=pointer-arith]
  922 |         wl_array_for_each(state_p, states) {
      |                           ^

A possible workaround is one used by the RetroArch team[2].

Something like this seems to fix the problem:

@@ -16,6 +16,27 @@
 //  along with this program; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
+/*  RetroArch - A frontend for libretro.
+ *  Copyright (C) 2010-2014 - Hans-Kristian Arntzen
+ *  Copyright (C) 2011-2017 - Daniel De Matteis
+ *
+ *  RetroArch is free software: you can redistribute it and/or modify it under the terms
+ *  of the GNU General Public License as published by the Free Software Found-
+ *  ation, either version 3 of the License, or (at your option) any later version.
+ *
+ *  RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ *  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ *  PURPOSE.  See the GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along with RetroArch.
+ *  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define WL_ARRAY_FOR_EACH(pos, array, type) \
+    for (pos = (type)(array)->data; \
+            (const char *) pos < ((const char *) (array)->data + (array)->size); \
+            (pos)++)
+
 #include "CIrrDeviceWaylandKeycodesWorkaround.h"
 
 #include "CIrrDeviceWayland.h"
@@ -852,9 +873,9 @@ public:
     {
         CIrrDeviceWayland* device = static_cast<CIrrDeviceWayland*>(data);
 
-        void* state_p;
+        const uint32_t* state_p;
         bool fullscreen = false;
-        wl_array_for_each(state_p, states) {
+        WL_ARRAY_FOR_EACH(state_p, states, const uint32_t*) {
             if(*(xdg_toplevel_state*)state_p == XDG_TOPLEVEL_STATE_FULLSCREEN) {
                 fullscreen = true;
             }
@@ -917,9 +938,9 @@ public:
     {
         CIrrDeviceWayland* device = static_cast<CIrrDeviceWayland*>(data);
 
-        void* state_p;
+        const uint32_t* state_p;
         bool fullscreen = false;
-        wl_array_for_each(state_p, states) {
+        WL_ARRAY_FOR_EACH(state_p, states, const uint32_t*) {
             if(*(zxdg_toplevel_v6_state*)state_p == ZXDG_TOPLEVEL_V6_STATE_FULLSCREEN) {
                 fullscreen = true;
             }

[0] https://gitlab.freedesktop.org/wayland/wayland/-/issues/34
[1] https://gcc.gnu.org/onlinedocs/gcc-11.2.0/gcc/Pointer-Arith.html
[2] libretro/RetroArch@8e638f4

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.