Path: utzoo!attcan!uunet!husc6!ukma!rutgers!mit-eddie!uw-beaver!microsoft!tonyw From: tonyw@microsoft.UUCP (Tony Williams) Newsgroups: comp.lang.c Subject: Re: lint warning messages with malloc() Message-ID: <1169@microsoft.UUCP> Date: 5 Nov 88 01:42:18 GMT References: <142@cjsa.WA.COM> <355@marob.MASA.COM> Reply-To: tonyw@microsoft.UUCP (Tony Williams) Organization: Microsoft Corp., Redmond WA Lines: 26 In article <355@marob.MASA.COM> daveh@marob.masa.com (Dave Hammond) writes: |In article <142@cjsa.WA.COM> jeff@cjsa.WA.COM (Jeffery Small) writes: |>When compiling a program on an AT&T 3B1 (running SystemV.2 +/-), I am |>getting the following warning message from lint when I use malloc(3): |> |> warning: possible pointer alignment problem |>[...sample code deleted...] | |The program code is not at fault. The problem is that lint does not |know about malloc returning a suitably aligned pointer, therefore |it complains. You could do some fancy declaration footwork and declare | |X *malloc(); DO NOT DO THIS. Since you are using lint, I assume you care somewhat about portability :-). There are machines out there for which struct X * and char * have different representations. On these machines, malloc will return the char* representation and you must have the cast to convert it. For the same reason, you must have a declaration extern char* malloc(); in your programs, so that the compiler does not assume it is int. I am afraid that we just have to live with some features of lint. Tony Williams