Compilator warning

Ask anything your want about Megadrive/Genesis programming.

Moderator: BigEvilCorporation

Post Reply
KanedaFr
Administrateur
Posts: 1139
Joined: Tue Aug 29, 2006 10:56 am
Contact:

Compilator warning

Post by KanedaFr » Thu Oct 18, 2007 10:16 pm

For all gcc guru, I just lost some times on a...'problem'

I renamed a function and create another one with the same name as the previous.
The renamed is in the .H file, the new one with the older name is not.

When I compile, I have no error nor warnings while another C file still call the older name function
:arrow: how the .C file could call a private function (not in the .H file)
:arrow: how GCC won't cry while the number of arguments is different (2 vs 0)

I think it's a param for gcc compiler to be more strict but, well...you see...I don't know gcc params ;)

I'm at 100% for strict warnings so how can I active strong checking ?


ho, yes, before you ask, it's still my good ol'one XGCC compiler ;)

ps: I post it in Megadrive/Genesis subtopic because it could be a XGCC failure...
Last edited by KanedaFr on Fri Oct 26, 2007 11:31 am, edited 2 times in total.

Fonzie
Genny lover
Posts: 323
Joined: Tue Aug 29, 2006 11:17 am
Contact:

Post by Fonzie » Thu Oct 18, 2007 10:37 pm

Did u delete all the temp files (.o and others)? Sometimes it happen to me, and deleting all the files make it work again.

I also saw a bug of gcc confusing functions names (like play_pcm(); beeing confused by play_pcm_ok();)... There must be a bug somewhere too.

KanedaFr
Administrateur
Posts: 1139
Joined: Tue Aug 29, 2006 10:56 am
Contact:

Post by KanedaFr » Thu Oct 18, 2007 11:07 pm

Ok...I think it's time to move to Code::Block ;)

KanedaFr
Administrateur
Posts: 1139
Joined: Tue Aug 29, 2006 10:56 am
Contact:

Post by KanedaFr » Fri Oct 19, 2007 6:21 am

...it's -Wall ... :oops:

I switched to StefDevKit's GCC.
After a fight with asm file and a bug in the .ld file, I finally produce my binary...which lose 20k (on 64k)!!
ok, I vote, XGCC is now history!!! :)

hop, jump to Eclipse configuration...next week

Edge-`
Interested
Posts: 39
Joined: Sun Dec 10, 2006 3:26 am

Post by Edge-` » Fri Oct 19, 2007 1:03 pm

Yeah, Stef's GCC is quite nice :), I liked XGCC, but still isn't as nice as the version of GCC that Stef includes.
Genny Wars (Someday.. :D)

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Fri Oct 19, 2007 5:13 pm

KanedaFr wrote:...it's -Wall ... :oops:

I switched to StefDevKit's GCC.
After a fight with asm file and a bug in the .ld file, I finally produce my binary...which lose 20k (on 64k)!!
ok, I vote, XGCC is now history!!! :)

hop, jump to Eclipse configuration...next week
Seems a lot of guys has trouble with the .LD file, specially on linux system. What sort of bug you meet ? i need to fix that for the next version :)

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Fri Oct 19, 2007 5:52 pm

Stef wrote:
KanedaFr wrote:...it's -Wall ... :oops:

I switched to StefDevKit's GCC.
After a fight with asm file and a bug in the .ld file, I finally produce my binary...which lose 20k (on 64k)!!
ok, I vote, XGCC is now history!!! :)

hop, jump to Eclipse configuration...next week
Seems a lot of guys has trouble with the .LD file, specially on linux system. What sort of bug you meet ? i need to fix that for the next version :)
This is the one we worked out for me in linux.

Code: Select all

OUTPUT_ARCH(m68k)
SEARCH_DIR(.)
/*GROUP(-lbcc -lc -lgcc)*/
__DYNAMIC  =  0;

/*
 * Setup the memory map of the SEGA Genesis.
 * stack grows down from high memory.
 *
 * The memory map look like this:
 * +--------------------+ <- low memory
 * | .text              |
 * |        _etext      |
 * |        ctor list   | the ctor and dtor lists are for
 * |        dtor list   | C++ support
 * +--------------------+
 * | .data              | initialized data goes here
 * |        _edata      |
 * +--------------------+
 * | .bss               |
 * |        __bss_start | start of bss, cleared by crt0
 * |        _end        | start of heap, used by sbrk()
 * +--------------------+
 * .                    .
 * .                    .
 * .                    .
 * |        __stack     | top of stack
 * +--------------------+
 */
MEMORY
{
    rom : ORIGIN = 0x00000000, LENGTH = 0x00400000
    ram : ORIGIN = 0x00ff0000, LENGTH = 0x00010000
  }

/*
 * allocate the stack to be at the top of memory, since the stack
 * grows down
 */

PROVIDE (__stack = 0x00fffff0);

/*
 * Initalize some symbols to be zero so we can reference them in the
 * crt0 without core dumping. These functions are all optional, but
 * we do this so we can have our crt0 always use them if they exist.
 * This is so BSPs work better when using the crt0 installed with gcc.
 * We have to initalize them twice, so we cover a.out (which prepends
 * an underscore) and coff object file formats.
 */
PROVIDE (hardware_init_hook = 0);
PROVIDE (_hardware_init_hook = 0);
PROVIDE (software_init_hook = 0);
PROVIDE (_software_init_hook = 0);

SECTIONS
{
  .text 0x00000000:
  {
    *(.text)
    . = ALIGN(0x4);
     __CTOR_LIST__ = .;
    LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
    *(.ctors)
    LONG(0)
    __CTOR_END__ = .;
    __DTOR_LIST__ = .;
    LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)
    *(.dtors)
     LONG(0)
    __DTOR_END__ = .;
    *(.rodata*)
    *(.gcc_except_table)

    __INIT_SECTION__ = . ;
    *(.init)
    SHORT (0x4e75)    /* rts */

    __FINI_SECTION__ = . ;
    *(.fini)
    SHORT (0x4e75)    /* rts */

    _etext = .;
    *(.lit)
  } > rom

  .data 0xff0000 :
  {
    *(.shdata)
    *(.data)
    _edata = .;
  } > ram

  .bss 0xff0000 :
  {
    __bss_start = . ;
    *(.shbss)
    *(.bss)
    *(COMMON)
    *(.eh_fram)
    *(.eh_frame)
    _end =  ALIGN (0x8);
    __end = _end;
  } > ram

  .stab 0 (NOLOAD) :
  {
    *(.stab)
  }

  .stabstr 0 (NOLOAD) :
  {
    *(.stabstr)
  }
}
I'm also using the latest gcc for uclinux toolchain - 4.1.1 from here:
http://www.uclinux.org/pub/uClinux/m68k ... 14.tar.bz2

Just remember to use the 68000 version of the libgcc.a file. The default one used by uclinux is for higher 68ks. They have a directory in the arc that has the 68000 version. Once you have the md.ld above and the proper libgcc.a, it works great. I'm using it in CodeBlocks in Fedora 7.

Now I need to make a compiler setting and ld file for Sega CD...

ElBarto
Very interested
Posts: 160
Joined: Wed Dec 13, 2006 10:29 am
Contact:

Post by ElBarto » Fri Oct 19, 2007 7:01 pm

I use the same .ld file for gcc-4.2.0, works fine too.

8bitwizard
Very interested
Posts: 159
Joined: Sat Feb 24, 2007 11:35 pm
Location: San Antonio, TX

Post by 8bitwizard » Sat Oct 20, 2007 4:20 am

As long as we're all showing off our linker scripts, here's the one I ended up with after getting someone's OS X-based GCC 3.4.4 working. It was a total pain to get initialized global data working. It's not great, but it may have something in it that someone will find useful:

Code: Select all

SECTIONS 
{
  .text 0x00000000:
  {
	. = ALIGN(2);
	*(.text)
	. = ALIGN(2);
	*(.rodata) 
	. = ALIGN(2);
	*(.rodata.*)
  _etext = .;
  } = 0xFF

  .data 0xFFFF0000:
  AT (_etext)
  {
  _data = .;
	. = ALIGN (2);

	*(.data)
  _edata = .;
  } = 0xFF

 .bss :
 {
	. = ALIGN(2);
	*(.bss)
	. = ALIGN(2);
	*(COMMON)
 }
}
I still couldn't get a glibc working and had to find my own memcpy. I tried to get a gcc 4.x working first, but it was just too complicated to get an m68k GCC built. Building your own cross-gcc is not trivial.

Anyhow, after getting a hello-world working, I haven't had any time to do my own coding, because of my real job. But at least the real job puts money in the bank.

Fonzie
Genny lover
Posts: 323
Joined: Tue Aug 29, 2006 11:17 am
Contact:

Post by Fonzie » Sat Oct 20, 2007 10:43 am

Does code blocks allow you to have a different .ld per project?
Because, for a simple megacd game, you have minimum of 3 .ld , and each game is different ^^.

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Sat Oct 20, 2007 4:32 pm

Fonzie wrote:Does code blocks allow you to have a different .ld per project?
Because, for a simple megacd game, you have minimum of 3 .ld , and each game is different ^^.
You can set per project compiler choice, linker options, etc. If you follow the guides here, you setup a special compiler setting specifically aimed at the Genesis, then choose it in the project prefs. My aim for SEGA CD is to set up another that handles the Genesis while the CD is active, and yet another for the CD part. I guess that's the three you are talking about.

Fonzie
Genny lover
Posts: 323
Joined: Tue Aug 29, 2006 11:17 am
Contact:

Post by Fonzie » Sat Oct 20, 2007 9:47 pm

Ok nice :)
I'll maybe give a try at code blocks one day :D

Yeah, masterboot.ld, slaveboot.ld mastercode.ld is the "minimum" :P (tavern rpg have 11 .ld files, for more insane pleasure!)

KanedaFr
Administrateur
Posts: 1139
Joined: Tue Aug 29, 2006 10:56 am
Contact:

Post by KanedaFr » Wed Oct 24, 2007 9:47 am

KanedaFr wrote: hop, jump to Eclipse configuration...next week
my...!!!
I didn't think use of Eclipse CDT will be so easy!!!!
ok ok, I use the makefile method but it's all i need!!!
plus eclipse analyse the .o created!!!!
so coooooooool!!

Post Reply