public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Void pointer arithmetic
@ 2007-05-17 21:45 Sven Eschenberg
  2007-05-18  5:29 ` Michael Eager
  0 siblings, 1 reply; 3+ messages in thread
From: Sven Eschenberg @ 2007-05-17 21:45 UTC (permalink / raw)
  To: gcc-help

Hi list,

Long time ago I wrote a small application, well back when g++ didn't 
even insist on std::cout. Now, since I upgrade g++ and tried to compile 
the application, g++ threw errors and warnings in masses. Most of the 
stuff I could fix, but I am stuck with the following problem:

/usr/include/linux/netfilter_ipv4/ip_tables.h: In function 
'xt_entry_target* ipt_get_target(ipt_entry*)':
/usr/include/linux/netfilter_ipv4/ip_tables.h:225: error: pointer of 
type 'void *' used in arithmetic
/usr/include/linux/netfilter_ipv4/ip_tables.h:225: error: invalid 
conversion from 'void*' to 'xt_entry_target*'

Is there any chance of fixing the problem without tweaking the kernel 
includes (the running kernel is kinda ancient, but updates are a little 
difficult)?

Thnx

-Sven

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Void pointer arithmetic
  2007-05-17 21:45 Void pointer arithmetic Sven Eschenberg
@ 2007-05-18  5:29 ` Michael Eager
  2007-05-18 11:01   ` Sven Eschenberg
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Eager @ 2007-05-18  5:29 UTC (permalink / raw)
  To: Sven Eschenberg; +Cc: gcc-help

Sven Eschenberg wrote:
> Hi list,
> 
> Long time ago I wrote a small application, well back when g++ didn't 
> even insist on std::cout. Now, since I upgrade g++ and tried to compile 
> the application, g++ threw errors and warnings in masses. Most of the 
> stuff I could fix, but I am stuck with the following problem:
> 
> /usr/include/linux/netfilter_ipv4/ip_tables.h: In function 
> 'xt_entry_target* ipt_get_target(ipt_entry*)':
> /usr/include/linux/netfilter_ipv4/ip_tables.h:225: error: pointer of 
> type 'void *' used in arithmetic
> /usr/include/linux/netfilter_ipv4/ip_tables.h:225: error: invalid 
> conversion from 'void*' to 'xt_entry_target*'
> 
> Is there any chance of fixing the problem without tweaking the kernel 
> includes (the running kernel is kinda ancient, but updates are a little 
> difficult)?

Cast the (void *) to (char *).

It's not clear what the type of xt_entry_target is.  If it
is a pointer, then there should be no problem converting.


-- 
Michael Eager	 eager@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Void pointer arithmetic
  2007-05-18  5:29 ` Michael Eager
@ 2007-05-18 11:01   ` Sven Eschenberg
  0 siblings, 0 replies; 3+ messages in thread
From: Sven Eschenberg @ 2007-05-18 11:01 UTC (permalink / raw)
  To: Michael Eager; +Cc: gcc-help

On Thu, 2007-05-17 at 22:29 -0700, Michael Eager wrote:
> Sven Eschenberg wrote:
> > Hi list,
> > 
> > Long time ago I wrote a small application, well back when g++ didn't 
> > even insist on std::cout. Now, since I upgrade g++ and tried to compile 
> > the application, g++ threw errors and warnings in masses. Most of the 
> > stuff I could fix, but I am stuck with the following problem:
> > 
> > /usr/include/linux/netfilter_ipv4/ip_tables.h: In function 
> > 'xt_entry_target* ipt_get_target(ipt_entry*)':
> > /usr/include/linux/netfilter_ipv4/ip_tables.h:225: error: pointer of 
> > type 'void *' used in arithmetic
> > /usr/include/linux/netfilter_ipv4/ip_tables.h:225: error: invalid 
> > conversion from 'void*' to 'xt_entry_target*'
> > 
> > Is there any chance of fixing the problem without tweaking the kernel 
> > includes (the running kernel is kinda ancient, but updates are a little 
> > difficult)?
> 
> Cast the (void *) to (char *).
> 
> It's not clear what the type of xt_entry_target is.  If it
> is a pointer, then there should be no problem converting.
> 
> 

Well, the funny thing is, the pointer is casted to void *, and then
returned, the inline functions return type is a different type anyway,
so I changed it to the return type which pretty much does the job.
Still, feels uncomfortable, that I had to change the header (which is
from a pretty recent kernel headers package).

-Sven


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-05-18 11:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-17 21:45 Void pointer arithmetic Sven Eschenberg
2007-05-18  5:29 ` Michael Eager
2007-05-18 11:01   ` Sven Eschenberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).