Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Determining the 'type' of a variable, if only its name is given |
| Date | 2012-06-16 09:27 +1200 |
| Message-ID | <a41nlfFg0U1@mid.individual.net> (permalink) |
| References | <caa6501b-646a-4ca3-85a2-a15bf7271d90@h41g2000yqm.googlegroups.com> <966f3de9-bf1f-418a-b3e0-fbeecfa241a5@j10g2000yqd.googlegroups.com> <4FDB48C6.6030802@loria.fr> |
On 06/16/12 02:37 AM, Jens Gustedt wrote: > Am 15.06.2012 10:51, schrieb John Reye: >> is it possible, to determine the 'type' of a variable, if only its >> name is given. > > [snip things about oldish C99] > >> Is there any other way, to determine if a variable var is signed or >> unsigned, if sizeof(var)< sizeof(int) ??? > > with C11's _Generic you may do that, provided your implementation > hasn't extended integer types that are narrower than int, > > you can do something horrible like > <snip something horrible> > > > - the case for "char" works since "unsigned char" can't have padding > bits > - _Bool is unsigned per definition > - then for all cases you have to distinguish all qualified types. at > least as quickly I didn't come up with an idea that would force an > conversion to an rvalue such that it would drop all qualifiers, and > wouldn't promote to the rank of "int" This could go in a header somewhere: it's similar to C++'s use of the numeric_limits template. -- Ian Collins
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Determining the 'type' of a variable, if only its name is given John Reye <jononanon@googlemail.com> - 2012-06-15 01:47 -0700
Re: Determining the 'type' of a variable, if only its name is given John Reye <jononanon@googlemail.com> - 2012-06-15 01:51 -0700
Re: Determining the 'type' of a variable, if only its name is given James Kuyper <jameskuyper@verizon.net> - 2012-06-15 08:18 -0400
Re: Determining the 'type' of a variable, if only its name is given "BartC" <bc@freeuk.com> - 2012-06-15 13:43 +0100
Re: Determining the 'type' of a variable, if only its name is given Noob <root@127.0.0.1> - 2012-06-15 17:02 +0200
Re: Determining the 'type' of a variable, if only its name is given Robert Miles <milesrf@Usenet-News.net> - 2012-07-23 23:20 -0500
Re: Determining the 'type' of a variable, if only its name is given pete <pfiland@mindspring.com> - 2012-06-15 08:21 -0400
Re: Determining the 'type' of a variable, if only its name is given Jens Gustedt <jens.gustedt@loria.fr> - 2012-06-15 16:37 +0200
Re: Determining the 'type' of a variable, if only its name is given Ian Collins <ian-news@hotmail.com> - 2012-06-16 09:27 +1200
Re: Determining the 'type' of a variable, if only its name is given Jens Gustedt <jens.gustedt@loria.fr> - 2012-06-16 09:38 +0200
Re: Determining the 'type' of a variable, if only its name is given Tim Rentsch <txr@alumni.caltech.edu> - 2012-06-22 20:42 -0700
Re: Determining the 'type' of a variable, if only its name is given Jens Gustedt <jens.gustedt@loria.fr> - 2012-06-23 14:41 +0200
Re: Determining the 'type' of a variable, if only its name is given Tim Rentsch <txr@alumni.caltech.edu> - 2012-06-24 10:15 -0700
Re: Determining the 'type' of a variable, if only its name is given Tim Rentsch <txr@alumni.caltech.edu> - 2012-06-22 20:31 -0700
csiph-web