Re: [Freedos-devel] multiple defintions of all functions in the program compiled and in the library

2024-11-11 Thread Paul Dufresne via Freedos-devel
 Le lun., 11 nov. 2024 17:34:17 -0500 Rugxulo via Freedos-devel  a écrit 

 > Presumably this will solve your problem:
 > 
 > -fgnu89-inline
 > 
 > * https://gcc.gnu.org/onlinedocs/gcc/Inline.html
 > 
 > N.B. GCC 14.2 is by default using "gnu17" dialect (aka, C17 w/ GNU
 > extensions), IIRC.
 
Indeed -fgnu89-inline does solve my problem! Thanks!


___
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel


Re: [Freedos-devel] multiple defintions of all functions in the program compiled and in the library

2024-11-11 Thread Rugxulo via Freedos-devel
Hi,

On Mon, Nov 11, 2024 at 5:58 AM Paul Dufresne via Freedos-devel
 wrote:
>
> The place where functions of the library should be... is in the library... 
> not in the program that include the library.
>
> Only prototypes... should be in the program .h files.
> If a function is inline... it's name should not be exported... so I believe 
> it should be static too.
>
> Maybe that's the solution... don't make inline functions external... it does 
> not make a lot of sense...
> but make them static... so that they are not seen outside of the program that 
> use them.

Presumably this will solve your problem:

-fgnu89-inline

* https://gcc.gnu.org/onlinedocs/gcc/Inline.html

N.B. GCC 14.2 is by default using "gnu17" dialect (aka, C17 w/ GNU
extensions), IIRC.

"The default, if no C language dialect options are given, is -std=gnu17."

* https://gcc.gnu.org/onlinedocs/gcc/Standards.html#index-std


___
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel


Re: [Freedos-devel] multiple defintions of all functions in the program compiled and in the library

2024-11-11 Thread Louis Santillan via Freedos-devel
You might want to just borrow the bits here (
https://www.mrdictionary.net/allegro/).

On Mon, Nov 11, 2024 at 3:58 AM Paul Dufresne via Freedos-devel <
freedos-devel@lists.sourceforge.net> wrote:

> Thinking about it...
>
> The place where functions of the library should be... is in the library...
> not in the program that include the library.
> Well I wrote previous sentence, then change the order, then change it
> again... it still not so obvious to me.
> But I guess it should be!
>
> Only prototypes... should be in the program .h files.
> If a function is inline... it's name should not be exported... so I
> believe it should be static too.
>
> Maybe that's the solution... don't make inline functions external... it
> does not make a lot of sense...
> but make them static... so that they are not seen outside of the program
> that use them.
>
>
> ___
> Freedos-devel mailing list
> Freedos-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/freedos-devel
>
___
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel


Re: [Freedos-devel] multiple defintions of all functions in the program compiled and in the library

2024-11-11 Thread Paul Dufresne via Freedos-devel
Thinking about it...

The place where functions of the library should be... is in the library... not 
in the program that include the library.
Well I wrote previous sentence, then change the order, then change it again... 
it still not so obvious to me.
But I guess it should be!

Only prototypes... should be in the program .h files.
If a function is inline... it's name should not be exported... so I believe it 
should be static too.

Maybe that's the solution... don't make inline functions external... it does 
not make a lot of sense...
but make them static... so that they are not seen outside of the program that 
use them.


___
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel


Re: [Freedos-devel] multiple defintions of all functions in the program compiled and in the library

2024-11-10 Thread Louis Santillan via Freedos-devel
gcc tools/dat2c.c -o dat2c.exe -I./include
ought to be something like
gcc tools/dat2c.c -o dat2c.exe -I./include -lalleg
or
gcc tools/dat2c.c -o dat2c.exe -I./include -lalleg -L
if it is not where the rest of the DJGPP libraries are.  That should have
been taken care of by `make install`.



On Sun, Nov 10, 2024 at 3:28 PM Paul Dufresne via Freedos-devel <
freedos-devel@lists.sourceforge.net> wrote:

> It's not really all the functions... it's the one that are defined in the
> .h files.
> I have preprocessed a file with:
> gcc -E tools/dat2c.c -o dat2c.i -I./include
>
> and after that compare some symbols that are said to be duplicated:
>
> [paul@betakard allegro-4.2.3.1]$ grep _getpixel32 dat2c.i
> extern __inline__ int _getpixel32 (BITMAP *bmp, int x, int y); extern
> __inline__ int _getpixel32 (BITMAP *bmp, int x, int y) { unsigned int addr;
> int c; _farsetsel((bmp)->seg); addr = bmp_read_line(bmp, y); c =
> _farnspeekl(addr+x*sizeof(signed int)); bmp_unwrite_line(bmp); return c; }
> extern int _linear_getpixel32 (BITMAP *bmp, int x, int y);
>
> [paul@betakard allegro-4.2.3.1]$ grep is_sub_bitmap dat2c.i
> extern __inline__ int is_sub_bitmap (BITMAP *bmp); extern __inline__ int
> is_sub_bitmap (BITMAP *bmp) { ; return (bmp->id & 0x2000) != 0; }
>
> [paul@betakard allegro-4.2.3.1]$ grep _allegro_hline dat2c.i
> extern __inline__ void _allegro_hline (BITMAP *bmp, int x1, int y, int x2,
> int color); extern __inline__ void _allegro_hline (BITMAP *bmp, int x1, int
> y, int x2, int color) { ; bmp->vtable->hline(bmp, x1, y, x2, color); }
>static __attribute__((unused)) __inline__ void hline(BITMAP *bmp, int
> x1, int y, int x2, int color) { _allegro_hline(bmp, x1, y, x2, color); }
>
> [paul@betakard allegro-4.2.3.1]$ grep _putpixel15 dat2c.i
> extern __inline__ void _putpixel15 (BITMAP *bmp, int x, int y, int color);
> extern __inline__ void _putpixel15 (BITMAP *bmp, int x, int y, int color) {
> unsigned int addr; _farsetsel((bmp)->seg); addr = bmp_write_line(bmp, y);
> _farnspokew(addr+x*sizeof(short), color); bmp_unwrite_line(bmp); }
> extern void _linear_putpixel15 (BITMAP *bmp, int x, int y, int color);
>
> [paul@betakard allegro-4.2.3.1]$ grep clear_to_color dat2c.i
>void (*clear_to_color) (struct BITMAP *bitmap, int color);
> extern __inline__ void clear_to_color (BITMAP *bitmap, int color); extern
> __inline__ void clear_to_color (BITMAP *bitmap, int color) { ;
> bitmap->vtable->clear_to_color(bitmap, color); }
>
> Still not knowing how to fix that however.
>
>
>
>
> ___
> Freedos-devel mailing list
> Freedos-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/freedos-devel
>
___
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel


Re: [Freedos-devel] multiple defintions of all functions in the program compiled and in the library

2024-11-10 Thread Paul Dufresne via Freedos-devel
It's not really all the functions... it's the one that are defined in the .h 
files.
I have preprocessed a file with:
gcc -E tools/dat2c.c -o dat2c.i -I./include

and after that compare some symbols that are said to be duplicated:

[paul@betakard allegro-4.2.3.1]$ grep _getpixel32 dat2c.i
extern __inline__ int _getpixel32 (BITMAP *bmp, int x, int y); extern 
__inline__ int _getpixel32 (BITMAP *bmp, int x, int y) { unsigned int addr; int 
c; _farsetsel((bmp)->seg); addr = bmp_read_line(bmp, y); c = 
_farnspeekl(addr+x*sizeof(signed int)); bmp_unwrite_line(bmp); return c; }
extern int _linear_getpixel32 (BITMAP *bmp, int x, int y);

[paul@betakard allegro-4.2.3.1]$ grep is_sub_bitmap dat2c.i
extern __inline__ int is_sub_bitmap (BITMAP *bmp); extern __inline__ int 
is_sub_bitmap (BITMAP *bmp) { ; return (bmp->id & 0x2000) != 0; }

[paul@betakard allegro-4.2.3.1]$ grep _allegro_hline dat2c.i
extern __inline__ void _allegro_hline (BITMAP *bmp, int x1, int y, int x2, int 
color); extern __inline__ void _allegro_hline (BITMAP *bmp, int x1, int y, int 
x2, int color) { ; bmp->vtable->hline(bmp, x1, y, x2, color); }
   static __attribute__((unused)) __inline__ void hline(BITMAP *bmp, int x1, 
int y, int x2, int color) { _allegro_hline(bmp, x1, y, x2, color); }

[paul@betakard allegro-4.2.3.1]$ grep _putpixel15 dat2c.i
extern __inline__ void _putpixel15 (BITMAP *bmp, int x, int y, int color); 
extern __inline__ void _putpixel15 (BITMAP *bmp, int x, int y, int color) { 
unsigned int addr; _farsetsel((bmp)->seg); addr = bmp_write_line(bmp, y); 
_farnspokew(addr+x*sizeof(short), color); bmp_unwrite_line(bmp); }
extern void _linear_putpixel15 (BITMAP *bmp, int x, int y, int color);

[paul@betakard allegro-4.2.3.1]$ grep clear_to_color dat2c.i
   void (*clear_to_color) (struct BITMAP *bitmap, int color);
extern __inline__ void clear_to_color (BITMAP *bitmap, int color); extern 
__inline__ void clear_to_color (BITMAP *bitmap, int color) { ; 
bitmap->vtable->clear_to_color(bitmap, color); }

Still not knowing how to fix that however.




___
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel


Re: [Freedos-devel] multiple defintions of all functions in the program compiled and in the library

2024-11-10 Thread Paul Dufresne via Freedos-devel
I am now able to make a new alleg.a file  (with GCC 14.2 cross-compiling)...
but I cannot link a program file... either from the examples or from the one 
that come with
the library (make programs)... because apparently all the functions seems to be 
defined
both in the program and in the library.

It spits multiple definitions errors for about 2 mins before failing:
$ make tools/dat2s.exe
...
/usr/local/cross/lib/gcc/i386-pc-msdosdjgpp/14.2.0/../../../../i386-pc-msdosdjgpp/bin/ld:
 lib/djgpp/liballeg.a(fontbios.o):fontbios.c:(.text+0x17b0): multiple 
definition of `textout_justify'; 
obj/djgpp/alleg/dat2s.o:dat2s.c:(.text+0x3680): first defined here
/usr/local/cross/lib/gcc/i386-pc-msdosdjgpp/14.2.0/../../../../i386-pc-msdosdjgpp/bin/ld:
 lib/djgpp/liballeg.a(fontbios.o):fontbios.c:(.text+0x17f0): multiple 
definition of `draw_character'; obj/djgpp/alleg/dat2s.o:dat2s.c:(.text+0x36c0): 
first defined here
/usr/local/cross/lib/gcc/i386-pc-msdosdjgpp/14.2.0/../../../../i386-pc-msdosdjgpp/bin/ld:
 lib/djgpp/liballeg.a(fontbios.o):fontbios.c:(.text+0x1820): multiple 
definition of `gui_textout'; obj/djgpp/alleg/dat2s.o:dat2s.c:(.text+0x36f0): 
first defined here
/usr/local/cross/lib/gcc/i386-pc-msdosdjgpp/14.2.0/../../../../i386-pc-msdosdjgpp/bin/ld:
 lib/djgpp/liballeg.a(fontbios.o):fontbios.c:(.text+0x1860): multiple 
definition of `set_window_close_button'; 
obj/djgpp/alleg/dat2s.o:dat2s.c:(.text+0x3730): first defined here
/usr/local/cross/lib/gcc/i386-pc-msdosdjgpp/14.2.0/../../../../i386-pc-msdosdjgpp/bin/ld:
 lib/djgpp/liballeg.a(fontbios.o):fontbios.c:(.text+0x1870): multiple 
definition of `set_window_close_hook'; 
obj/djgpp/alleg/dat2s.o:dat2s.c:(.text+0x3740): first defined here
/usr/local/cross/lib/gcc/i386-pc-msdosdjgpp/14.2.0/../../../../i386-pc-msdosdjgpp/bin/ld:
 lib/djgpp/liballeg.a(fontbios.o):fontbios.c:(.text+0x1880): multiple 
definition of `yield_timeslice'; 
obj/djgpp/alleg/dat2s.o:dat2s.c:(.text+0x3750): first defined here
/usr/local/cross/lib/gcc/i386-pc-msdosdjgpp/14.2.0/../../../../i386-pc-msdosdjgpp/bin/ld:
 lib/djgpp/liballeg.a(fontbios.o):fontbios.c:(.text+0x18a0): multiple 
definition of `set_file_encoding'; 
obj/djgpp/alleg/dat2s.o:dat2s.c:(.text+0x3770): first defined here
/usr/local/cross/lib/gcc/i386-pc-msdosdjgpp/14.2.0/../../../../i386-pc-msdosdjgpp/bin/ld:
 lib/djgpp/liballeg.a(fontbios.o):fontbios.c:(.text+0x18b0): multiple 
definition of `get_file_encoding'; 
obj/djgpp/alleg/dat2s.o:dat2s.c:(.text+0x3780): first defined here
/usr/local/cross/lib/gcc/i386-pc-msdosdjgpp/14.2.0/../../../../i386-pc-msdosdjgpp/bin/ld:
 lib/djgpp/liballeg.a(fontbios.o):fontbios.c:(.text+0x18c0): multiple 
definition of `_set_color'; obj/djgpp/alleg/dat2s.o:dat2s.c:(.text+0x3790): 
first defined here
/usr/local/cross/lib/gcc/i386-pc-msdosdjgpp/14.2.0/../../../../i386-pc-msdosdjgpp/bin/ld:
 lib/djgpp/liballeg.a(fontbios.o):fontbios.c:(.text+0x18f0): multiple 
definition of `_grow_scratch_mem'; 
obj/djgpp/alleg/dat2s.o:dat2s.c:(.text+0x37c0): first defined here
collect2: error: ld returned 1 exit status
make: *** [makefile.all:536: tools/dat2s.exe] Error 1
[paul@betakard allegro-4.2.3.1]$ 

I belived to have build the lib with -fcommon... but -fcommon seems more about 
global variables then functions... I think.


___
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel