[comp.lang.c] void * not handled in AIX C compiler ?

johnny@edvvie.at (Johann Schweigl) (09/23/89)

AIX C allows the use of void functions, and the (void *) typecast.
Declaring a variable as void * does not work. The effect is the same
as if the variable had never been defined. Example:

main() {
	void *foo;
	int bar;

	foo = &bar;
}

results in:

"foo.c", line 6: foo undefined
"foo.c", line 6: warning: illegal combination of pointer and integer, op =

which is not quite correct.
Especially I see no sense behind supporting void * in a typecast but not
in a declaration. 
Am I wrong?
Any comments? 
-- 
       ------------------------------------------------------------------
       EDV Ges.m.b.H Vienna              Johann Schweigl    
       Hofmuehlgasse 3 - 5               USENET: johnny@edvvie.at
       A-1060 Vienna, Austria      Tel: (0043) (222) 59907 257 (8-19 CET)

comeau@utoday.UUCP (Greg Comeau) (10/04/89)

In article <159@eliza.edvvie.at> johnny@edvvie.at (Johann Schweigl) writes:
>AIX C... Declaring a variable as void * does not work. The effect is the same
>as if the variable had never been defined. Example:
>	main() { void *foo; int bar; foo = &bar;}
>results in:
>
>"foo.c", line 6: foo undefined
>"foo.c", line 6: warning: illegal combination of pointer and integer, op =
>
>which is not quite correct.

You do not appear to be wrong.  Although the warning is approopriate,
the error is not.

webb@bass.tcspa.ibm.com (Bill Webb) (10/04/89)

> AIX C allows the use of void functions, and the (void *) typecast.
> Declaring a variable as void * does not work. The effect is the same
> as if the variable had never been defined. ...
>        ------------------------------------------------------------------
>        EDV Ges.m.b.H Vienna              Johann Schweigl    
>        Hofmuehlgasse 3 - 5               USENET: johnny@edvvie.at
>        A-1060 Vienna, Austria      Tel: (0043) (222) 59907 257 (8-19 CET)

I'd say that you're right. The AOS 4.3 RT hc compilers all compiled the 
code without problem (except for warnings about not using variable foo).
Pcc on the other hand gave exactly the same complaints as the AIX compiler.

	foo = (void *) &bar;

If the AIX compiler claims to be ANSI (I'm not sure if it does), then
I'd suggest that you do report it as a bug and see if you can get it fixed.

----------------------------------------------------------------
The above views are my own, not necessarily those of my employer.
Bill Webb (IBM AWD Palo Alto), (415) 855-4457).
UUCP: ...!uunet!ibmsupt!webb

garnett@rpp386.cactus.org (John Garnett) (10/05/89)

In article <159@eliza.edvvie.at>, johnny@edvvie.at (Johann Schweigl) writes:
> AIX C allows the use of void functions, and the (void *) typecast.
> Declaring a variable as void * does not work. The effect is the same
> as if the variable had never been defined.

This problem appears only in the AIX/RT C Compiler.  The AIX PS/2
C compiler does allow void pointers to be declared AND used.
However, both the AIX/RT and AIX PS/2 versions of lint choke
on void pointers.

Somebody want to fix this one?
-- 
+---------------------------------------------+--------------------------+
| Namenet:   John W. Garnett                  |  Base 1.9                |
| Internet:  garnett@rpp386.cactus.org        |                          |
| Uucpnet:   {bigtex|texbell}!rpp386!garnett  | "It's almost binary."    |

johnny@edvvie.at (Johann Schweigl) (10/06/89)

From article <2398@ibmpa.UUCP>, by webb@bass.tcspa.ibm.com (Bill Webb):
> 
> If the AIX compiler claims to be ANSI (I'm not sure if it does), then
> I'd suggest that you do report it as a bug and see if you can get it fixed.

I've got a number of good explanations to this question. 
I sum up by citing Karl Heuer:

---
I believe that AIX C is not intended  to be an ANSI C compiler.  
(Which is currently right -- johnny)
AIX C supports "void" because it's been part of the language for a decade.                               
It does not support declaring variables as "void *" because this is 
a recent invention, and the compiler  has not yet been upgraded to support  
ANSI C.                               
                                      
Despite appearances, it does not support "void *" in a typecast,       
either.  The compiler accepts the construct, but it doesn't behave the  
way X3J11 says.                      
                                     
The reason that "void *" isn't even accepted in a declaration is because  
of an implementation detail of the compiler.  Since "void *" was a       
meaningless type in pre-ANSI C, the compiler used that particular         
bit-pattern internally to mean "no type", i.e. for undeclared variables. 
---

Thanks to you all, johnny
-- 
This does not reflect the   | Johann  Schweigl | DOS machines? 
opinions of my employer.    | johnny@edvvie.at | I don't hate DOS machines. 
I am busy enough by talking |                  | I just feel better when I
about my own ...            |   EDVG  Vienna   | don't see one ...