Fix -Werror=incompatible-pointer-types hard

This commit is contained in:
Mamoru TASAKA 2024-02-23 12:25:34 +09:00
commit f146682609
2 changed files with 182 additions and 8 deletions

View file

@ -0,0 +1,174 @@
--- opengl-0.10.0/ext/opengl/gl-1.0-1.1.c.types 2024-02-23 11:59:46.379472357 +0900
+++ opengl-0.10.0/ext/opengl/gl-1.0-1.1.c 2024-02-23 12:20:08.317748271 +0900
@@ -203,8 +203,9 @@ struct gl_endisable_args {
};
static VALUE
-gl_Enable1(struct gl_endisable_args *args)
+gl_Enable1(VALUE val)
{
+ struct gl_endisable_args *args = (struct gl_endisable_args *)val;
long i;
VALUE obj = args->obj;
DECL_GL_FUNC_PTR(void,glEnable,(GLenum cap));
@@ -220,9 +221,10 @@ gl_Enable1(struct gl_endisable_args *arg
}
static VALUE
-gl_Enable0(struct gl_endisable_args *args)
+gl_Enable0(VALUE val)
{
- gl_Enable1(args);
+ struct gl_endisable_args *args = (struct gl_endisable_args *)val;
+ gl_Enable1((VALUE)args);
if (rb_block_given_p())
rb_yield(Qundef);
@@ -231,8 +233,9 @@ gl_Enable0(struct gl_endisable_args *arg
}
static VALUE
-gl_Disable1(struct gl_endisable_args *args)
+gl_Disable1(VALUE val)
{
+ struct gl_endisable_args *args = (struct gl_endisable_args *)val;
long i;
VALUE obj = args->obj;
DECL_GL_FUNC_PTR(void,glDisable,(GLenum cap));
@@ -248,9 +251,10 @@ gl_Disable1(struct gl_endisable_args *ar
}
static VALUE
-gl_Disable0(struct gl_endisable_args *args)
+gl_Disable0(VALUE val)
{
- gl_Disable1(args);
+ struct gl_endisable_args *args = (struct gl_endisable_args *)val;
+ gl_Disable1((VALUE)args);
if (rb_block_given_p())
rb_yield(Qundef);
@@ -279,7 +283,7 @@ gl_Enable(int argc, VALUE *argv, VALUE o
return rb_ensure(gl_Enable0, (VALUE)&enargs, gl_Disable1, (VALUE)&disargs);
} else {
struct gl_endisable_args args = { obj, caps };
- gl_Enable0(&args);
+ gl_Enable0((VALUE)&args);
}
return Qnil;
@@ -306,7 +310,7 @@ gl_Disable(int argc, VALUE *argv, VALUE
return rb_ensure(gl_Disable0, (VALUE)&disargs, gl_Enable1, (VALUE)&enargs);
} else {
struct gl_endisable_args args = { obj, caps };
- gl_Disable0(&args);
+ gl_Disable0((VALUE)&args);
}
return Qnil;
@@ -318,8 +322,9 @@ struct gl_client_state_args {
};
static VALUE
-gl_EnableClientState1(struct gl_client_state_args *args)
+gl_EnableClientState1(VALUE val)
{
+ struct gl_client_state_args *args = (struct gl_client_state_args *)val;
long i;
VALUE obj = args->obj;
DECL_GL_FUNC_PTR(void,glEnableClientState,(GLenum cap));
@@ -335,9 +340,10 @@ gl_EnableClientState1(struct gl_client_s
}
static VALUE
-gl_EnableClientState0(struct gl_client_state_args *args)
+gl_EnableClientState0(VALUE val)
{
- gl_EnableClientState1(args);
+ struct gl_client_state_args *args = (struct gl_client_state_args *)val;
+ gl_EnableClientState1((VALUE)args);
if (rb_block_given_p())
rb_yield(Qundef);
@@ -346,8 +352,9 @@ gl_EnableClientState0(struct gl_client_s
}
static VALUE
-gl_DisableClientState1(struct gl_client_state_args *args)
+gl_DisableClientState1(VALUE val)
{
+ struct gl_client_state_args *args = (struct gl_client_state_args *)val;
long i;
VALUE obj = args->obj;
DECL_GL_FUNC_PTR(void,glDisableClientState,(GLenum cap));
@@ -363,9 +370,10 @@ gl_DisableClientState1(struct gl_client_
}
static VALUE
-gl_DisableClientState0(struct gl_client_state_args *args)
+gl_DisableClientState0(VALUE val)
{
- gl_DisableClientState1(args);
+ struct gl_client_state_args *args = (struct gl_client_state_args *)val;
+ gl_DisableClientState1((VALUE)args);
if (rb_block_given_p())
rb_yield(Qundef);
@@ -394,7 +402,7 @@ gl_EnableClientState(int argc, VALUE *ar
return rb_ensure(gl_EnableClientState0, (VALUE)&enargs, gl_DisableClientState1, (VALUE)&disargs);
} else {
struct gl_client_state_args args = { obj, ary };
- gl_EnableClientState0(&args);
+ gl_EnableClientState0((VALUE)&args);
}
return Qnil;
@@ -421,7 +429,7 @@ gl_DisableClientState(int argc, VALUE *a
return rb_ensure(gl_DisableClientState0, (VALUE)&disargs, gl_EnableClientState1, (VALUE)&enargs);
} else {
struct gl_client_state_args args = { obj, ary };
- gl_DisableClientState0(&args);
+ gl_DisableClientState0((VALUE)&args);
}
return Qnil;
@@ -433,8 +441,9 @@ struct gl_begin0_args {
};
static VALUE
-gl_Begin0(struct gl_begin0_args *args)
+gl_Begin0(VALUE val)
{
+ struct gl_begin0_args *args = (struct gl_begin0_args *)val;
VALUE obj = args->obj;
DECL_GL_FUNC_PTR(void,glBegin,(GLenum mode));
@@ -472,7 +481,7 @@ gl_Begin(VALUE obj, VALUE mode)
if (rb_block_given_p())
return rb_ensure(gl_Begin0, (VALUE)&args, gl_End, obj);
else
- gl_Begin0(&args);
+ gl_Begin0((VALUE)&args);
return Qnil;
}
@@ -525,8 +534,9 @@ struct gl_list_args {
};
static VALUE
-gl_NewList0(struct gl_list_args *args)
+gl_NewList0(VALUE val)
{
+ struct gl_list_args *args = (struct gl_list_args *) val;
GLuint list;
GLenum mode;
VALUE obj = args->obj;
@@ -563,7 +573,7 @@ gl_NewList(VALUE obj, VALUE list, VALUE
if (rb_block_given_p())
return rb_ensure(gl_NewList0, (VALUE)&args, gl_EndList, obj);
else
- gl_NewList0(&args);
+ gl_NewList0((VALUE)&args);
return Qnil;
}

View file

@ -1,6 +1,3 @@
# Skip -Werror=incompatilbe-pointer-types
#%%global build_type_safety_c 2
%global gem_name opengl
%bcond_with bootstrap
@ -17,7 +14,7 @@
Name: rubygem-%{gem_name}
Version: 0.10.0
Release: 29%{?dist}
Release: 30%{?dist}
Summary: An OpenGL wrapper for Ruby
# SPDX confirmed
@ -32,6 +29,8 @@ Source0: %{gem_name}-%{version}-clean.gem
Source1: create-clean-opengl-gem.sh
# http://www.gnu.org/licenses/old-licenses/gpl-1.0.txt
Source2: GPLv1.rubygem_opengl
# Fix for -Werror=incompatible-pointer-types
Patch0: opengl-0.10.0-pointer-types.patch
# MRI (CRuby) only
BuildRequires: gcc
@ -80,11 +79,9 @@ sed -i.minitest \
-e 's|MiniTest::Unit::TestCase|Minitest::Test|' \
lib/opengl/test_case.rb
%build
# Only add -Wno-error=incompatible-pointer-types
%global optflags_orig %optflags
%global optflags %optflags -Wno-error=incompatible-pointer-types
%patch -P0 -p1 -b .types
%build
gem build %{gem_name}.gemspec
%gem_install
@ -164,6 +161,9 @@ popd
%doc %{gem_instdir}/utils/
%changelog
* Fri Feb 23 2024 Mamoru TASAKA <mtasaka@fedoraproject.org> - 0.10.0-30
- Fix -Werror=incompatible-pointer-types hard
* Thu Feb 22 2024 Mamoru TASAKA <mtasaka@fedoraproject.org> - 0.10.0-29
- Explicitly add -Wno-error=incompatible-pointer-types only