From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28490 invoked by alias); 4 Mar 2002 14:36:02 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 28403 invoked from network); 4 Mar 2002 14:35:54 -0000 Received: from unknown (HELO mithra.pcigeomatics.com) (209.50.84.8) by sources.redhat.com with SMTP; 4 Mar 2002 14:35:54 -0000 Received: by mithra.pcigeomatics.com; id JAA20106; Mon, 4 Mar 2002 09:35:53 -0500 (EST) Received: from unknown(10.1.1.106) by mithra.pcigeomatics.com via smap (V5.0) id xma020066; Mon, 4 Mar 02 09:35:40 -0500 Received: from PCIgeomatics.com (loki.pcigeomatics.com [10.1.1.12]) by vidar.pcigeomatics.com (8.11.0/8.11.0) with ESMTP id g24EZeY01314; Mon, 4 Mar 2002 09:35:40 -0500 Received: (from cheng@localhost) by PCIgeomatics.com (8.11.6/8.11.6) id g24EX6b32257; Mon, 4 Mar 2002 09:33:06 -0500 From: Philip Cheng Message-Id: <200203041433.g24EX6b32257@PCIgeomatics.com> Subject: Re: Use of typeof To: ke-gcc@retriever.dyndns.org (Kevin Bailey) Date: Mon, 04 Mar 2002 06:36:00 -0000 Cc: gcc-help@gcc.gnu.org In-Reply-To: <20020302110414.S28462@hawk.ind.alcatel.com> from "Kevin Bailey" at Mar 02, 2002 11:04:14 AM X-Mailer: ELM [version 2.5 PL6] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-SW-Source: 2002-03/txt/msg00016.txt.bz2 Kevin: If you look at http://gcc.gnu.org/onlinedocs/gcc-3.0.3/gcc_5.html#SEC74 you will find that typeof is gcc extension. There are two ways of writing the argument to typeof: with an expression or with a type. Here is an example with an expression: typeof (x[0](1)) This assumes that x is an array of pointers to functions; the type described is that of the values of the functions. Here is an example with a typename as the argument: typeof (int *) Seems typeof does not work with the 2nd method. Maybe it is a gcc bug? Philip > > There is no such thing as typeof in C. > > However, there is in C++ so either rename your file to test.cc > or compile with -xc++. > > On Fri, Mar 01, 2002 at 11:01:18AM -0500, Philip Cheng wrote: > > I would like to use typeof to determine the type of a variable. > > However, I keep getting the error when I try to compile the program. > > > > test.c: In function `main': > > test.c:8: parse error before "typeof" > > > > Anyone knows how can I solve the problem? Thanks in advance for your help. > > > > Philip > > > > > > Here is my test program: > > > > #include > > > > main() > > { > > double dftest; > > dftest = 1.0; > > > > if (__builtin_types_compatible_p (typeof (dftest), double)) > > printf("It is double\n"); > > } >