gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS Misc > Invalid conversion from void* to foo*; disable this warning?

#84548 - HyperHacker - Tue May 23, 2006 7:40 am

I noticed that when I use malloc() and similar functions in DS apps, I always have to cast their return types (unless I'm actually using void*) or else it warns me about the conversion. (I use arm-elf-g++ to compile.) Can this warning be disabled? I know it's bad form, but I found that LAME generates several dozen of these warnings. (A lot of compilers don't seem to care about not casting void*.) I've tried fooling with the warning options but I only managed to make it create more warnings for trivial things like assigning an unsigned variable to a signed one.

[edit] Bah, the preview shows my full thread title but it gets cut off when I submit. >_>
_________________
I'm a PSP hacker now, but I still <3 DS.

#84579 - melw - Tue May 23, 2006 2:34 pm

I'm using the following:

Code:
arm-elf-g++ --no-warnings

#84585 - zzo38computer - Tue May 23, 2006 3:05 pm

melw wrote:
I'm using the following:

Code:
arm-elf-g++ --no-warnings


If your car stops working and you tape the gas meter to full, will that help? No.

I also get a lot of warnings but I can't figure out how to fix it, I don't care about --no-warnings option, I just see what written there anyways
_________________
Important: Please send messages about FWNITRO to the public forum, not privately to me.


Last edited by zzo38computer on Tue May 23, 2006 3:10 pm; edited 1 time in total

#84587 - Mrshlee - Tue May 23, 2006 3:09 pm

melw wrote:
I'm using the following:

Code:
arm-elf-g++ --no-warnings


Your.. a genius! give that man a nobel prize!
_________________
MrShlee.com
Projects
Dev-Scene
MyTechpedia

#84614 - melw - Tue May 23, 2006 6:52 pm

zzo38computer wrote:
If your car stops working and you tape the gas meter to full, will that help? No.

The man asked how to disable warnings. A simple answer to a simple question, that's all. :)

#84623 - HyperHacker - Tue May 23, 2006 7:36 pm

I want to disable one specific warning, not all of them. Most of the time they're quite useful (many failures are easily resolved by warning messages telling me I forgot some character here or there), but in this case they're just an artifact of someone else's not-quite-correct-but-still-working code. Hell if I'm going to go through and fix them all, there's like 200 of them and I already another fixed 50 or so. >_>
_________________
I'm a PSP hacker now, but I still <3 DS.

#84629 - DekuTree64 - Tue May 23, 2006 8:07 pm

I'd also much appreciate a proper warning reference. The gcc docs never seem to tell how to disable the pointless ones. Like, when building Chishm's FAT lib on devkitARM r18, I get lots of "attribute packed has no effect" or something like that, because some u8 variables are set to be packed. Yes, I'm aware that it has no effect, but isn't it safer to specify it than to do it selectively according to the variable type?
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku

#84647 - wintermute - Tue May 23, 2006 10:34 pm

DekuTree64 wrote:
I'd also much appreciate a proper warning reference. The gcc docs never seem to tell how to disable the pointless ones. Like, when building Chishm's FAT lib on devkitARM r18, I get lots of "attribute packed has no effect" or something like that, because some u8 variables are set to be packed. Yes, I'm aware that it has no effect, but isn't it safer to specify it than to do it selectively according to the variable type?


The struct should be packed, not individual elements i.e.

Code:

// Boot Sector - must be packed
typedef struct
{
   u8   jmpBoot[3];
   u8   OEMName[8];
   // BIOS Parameter Block
   u16   bytesPerSector;
   u8   sectorsPerCluster;
   u16   reservedSectors;
   u8   numFATs;
   u16   rootEntries;
   u16   numSectorsSmall;
   u8   mediaDesc;
   u16   sectorsPerFAT;
   u16   sectorsPerTrk;
   u16   numHeads;
   u32   numHiddenSectors;
   u32   numSectors;
   union   // Different types of extended BIOS Parameter Block for FAT16 and FAT32
   {
      struct 
      {
         // Ext BIOS Parameter Block for FAT16
         u8   driveNumber;
         u8   reserved1;
         u8   extBootSig;
         u32   volumeID;
         u8   volumeLabel[11];
         u8   fileSysType[8];
         // Bootcode
         u8   bootCode[448];
      }   __PACKED fat16;
      struct 
      {
         // FAT32 extended block
         u32   sectorsPerFAT32;
         u16   extFlags;
         u16   fsVer;
         u32   rootClus;
         u16   fsInfo;
         u16   bkBootSec;
         u8   reserved[12];
         // Ext BIOS Parameter Block for FAT16
         u8   driveNumber;
         u8   reserved1;
         u8   extBootSig;
         u32   volumeID;
         u8   volumeLabel[11];
         u8   fileSysType[8];
         // Bootcode
         u8   bootCode[420];
      }   __PACKED fat32;
   }   __PACKED extBlock;

   u16   bootSig;

}   __PACKED BOOT_SEC;

// Directory entry - must be packed
typedef struct
{
   u8   name[8];
   u8   ext[3];
   u8   attrib;
   u8   reserved;
   u8   cTime_ms;
   u16   cTime;
   u16   cDate;
   u16   aDate;
   u16   startClusterHigh;
   u16   mTime;
   u16   mDate;
   u16   startCluster;
   u32   fileSize;
}   __PACKED DIR_ENT;

// Long file name directory entry - must be packed
typedef struct
{
   u8 ordinal;   // Position within LFN
   u16 char0;   
   u16 char1;
   u16 char2;
   u16 char3;
   u16 char4;
   u8 flag;   // Should be equal to ATTRIB_LFN
   u8 reserved1;   // Always 0x00
   u8 checkSum;   // Checksum of short file name (alias)
   u16 char5;
   u16 char6;
   u16 char7;
   u16 char8;
   u16 char9;
   u16 char10;
   u16 reserved2;   // Always 0x0000
   u16 char11;
   u16 char12;
}   __PACKED DIR_ENT_LFN;

_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog

#84716 - chishm - Wed May 24, 2006 11:14 am

wintermute wrote:

The struct should be packed, not individual elements i.e.

You'd think so, and so did I. However, I found it didn't work that way. I decided to stop with the compiler dependent packing, and extract the values using an enum of offsets.
_________________
http://chishm.drunkencoders.com
http://dldi.drunkencoders.com