Opened 12 years ago

Closed 12 years ago

Last modified 10 years ago

#39 closed defect (fixed)

mygetopt.c fails compilation on 64-bit FreeBSD

Reported by: Owned by: Jean-Yves Lamoureux
Priority: major Milestone:
Component: core Version: 0.99.beta13
Keywords: 64bit amd64 FreeBSD getopt mygetopt Cc:
Product: img2txt


Hello, mygetopt.c fails on amd64 FreeBSD:

cc -DHAVE_CONFIG_H -I. -I..  -I.. -I../cucul -I../caca -DLIBCACA=1 -DX_DISPLAY_MISSING=1 -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/include/freetype2 -O2 -fno-strict-aliasing -pipe  -fno-strength-reduce -Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wstrict-prototypes -Wshadow -Waggregate-return -Wmissing-prototypes -Wnested-externs -Wsign-compare -MT img2txt-img2txt.o -MD -MP -MF .deps/img2txt-img2txt.Tpo -c -o img2txt-img2txt.o `test -f 'img2txt.c' || echo './'`img2txt.c
mv -f .deps/img2txt-img2txt.Tpo .deps/img2txt-img2txt.Po
cc -DHAVE_CONFIG_H -I. -I..  -I.. -I../cucul -I../caca -DLIBCACA=1 -DX_DISPLAY_MISSING=1 -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/include/freetype2 -O2 -fno-strict-aliasing -pipe  -fno-strength-reduce -Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wstrict-prototypes -Wshadow -Waggregate-return -Wmissing-prototypes -Wnested-externs -Wsign-compare -MT img2txt-mygetopt.o -MD -MP -MF .deps/img2txt-mygetopt.Tpo -c -o img2txt-mygetopt.o `test -f 'mygetopt.c' || echo './'`mygetopt.c
mygetopt.c:29: error: conflicting types for 'uintptr_t'
/usr/include/stdint.h:102: error: previous declaration of 'uintptr_t' was here
mygetopt.c: In function 'mygetopt':
mygetopt.c:46: warning: cast from pointer to integer of different size
mygetopt.c:46: warning: cast to pointer from integer of different size
*** Error code 1

1) There is some strange construct like this (mygetopt.c:46):

     char **argv = (char **)(uintptr_t)_argv;

What is this needed for?

2) and above (mygetopt.c:29):

#ifndef __intptr_t_defined
typedef unsigned int            uintptr_t;

3) I had to change this to:

typedef unsigned int            uintptr_t;

and now 64-bit pointers are working.

On the other hand, since we have:

% grep -i getopt /usr/obj//usr/ports/graphics/libcaca/work/libcaca-0.99.beta13/config.h    
/* Define to 1 if you have the <getopt.h> header file. */
#define HAVE_GETOPT_H 1
/* Define to 1 if you have the `getopt_long' function. */

the "mygetopt.[ch]" code isn't going to be used at all. Maybe it makes sense to skip building this component altogether?



Change History (2)

comment:1 Changed 12 years ago by Sam Hocevar

Resolution: fixed
Status: newclosed

(In [1815]) * Don't use mygetopt.c in img2txt if the system has getopt_long.

  • Fix invalid pointer/int cast (Closes #39).

comment:2 Changed 10 years ago by Sam Hocevar

Component: img2txtcore
Product: img2txt
Note: See TracTickets for help on using tickets.