Seen in another place:
--------
typedef void my_lib_void;
my_lib_void my_lib_func(my_lib_void);
--------
(summarized from what should be appearing at
<http://yossi.kreinin.hates-software.com/2007/07/10/7a21fc28.html>
eventually, though it's broken as I'm writing this)
This is perfectly valid C; I don't know why anybody would actually WANT
to do it, but that apparently doesn't stop people.
It's reported that a C++ compiler will choke on it, though.
dave
--
Dave Vandervies dj******@csclub.uwaterloo.ca
I wonder if Canada could take out the US in a surprise attack? ... [A]s long
as the armored vehicles didn't try to use Canadian coins on the toll roads,
there might not be any resistance from state or local authorities. --Kevin, SDM 18 1263 dj******@csclub.uwaterloo.ca (Dave Vandervies) writes:
Seen in another place:
--------
typedef void my_lib_void;
my_lib_void my_lib_func(my_lib_void);
--------
Wow. Only slightly more moronic than a certain library that
typedefs each of the standard C types to a similar name beginning
with "g", though.
--
char a[]="\n .CJacehknorstu";int putchar(int);int main(void){unsigned long b[]
={0x67dffdff,0x9aa9aa6a,0xa77ffda9,0x7da6aa6a,0xa6 7f6aaa,0xaa9aa9f6,0x11f6},*p
=b,i=24;for(;p+=!*p;*p/=4)switch(0[p]&3)case 0:{return 0;for(p--;i--;i--)case+
2:{i++;if(i)break;else default:continue;if(0)case 1:putchar(a[i&15]);break;}}}
I tried running following c++ code
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
typedef void my_lib_void;
printf("Hello void %d",sizeof(my_lib_void));
system("PAUSE");
return 0;
}
it gives an error on second line of main()..
but at same time if c code
int main()
{
typedef void my_lib_void;
printf("Hello void %d",sizeof(my_lib_void));
system("PAUSE");
return 0;
}
it works showing sizeof(my_lib_void) as 1
Can anyone explain why?
cheers,
Sumedh
On Jul 10, 7:39 pm, dj3va...@csclub.uwaterloo.ca (Dave Vandervies)
wrote:
Seen in another place:
--------
typedef void my_lib_void;
my_lib_void my_lib_func(my_lib_void);
--------
(summarized from what should be appearing at
<http://yossi.kreinin.hates-software.com/2007/07/10/7a21fc28.html>
eventually, though it's broken as I'm writing this)
This is perfectly valid C; I don't know why anybody would actually WANT
to do it, but that apparently doesn't stop people.
It's reported that a C++ compiler will choke on it, though.
dave
--
Dave Vandervies dj3va...@csclub.uwaterloo.ca
I wonder if Canada could take out the US in a surprise attack? ... [A]s long
as the armored vehicles didn't try to use Canadian coins on the toll roads,
there might not be any resistance from state or local authorities. --Kevin, SDM
sumedh wrote:
I tried running following c++ code
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
typedef void my_lib_void;
printf("Hello void %d",sizeof(my_lib_void));
system("PAUSE");
return 0;
}
it gives an error on second line of main()..
but at same time if c code
int main()
{
typedef void my_lib_void;
printf("Hello void %d",sizeof(my_lib_void));
system("PAUSE");
return 0;
}
it works showing sizeof(my_lib_void) as 1
Can anyone explain why?
Please don't top-post. Also post C++ related questions to a C++ group
like comp.lang.c++.
Both your programs make no sense. What's the point in trying to take
the size of a non-existent type? C++'s rules are strict enough to
prevent compilation, while in C it compiles with a diagnostic and
produces nonsense as result.
Ben Pfaff wrote:
dj******@csclub.uwaterloo.ca (Dave Vandervies) writes:
>Seen in another place: -------- typedef void my_lib_void; my_lib_void my_lib_func(my_lib_void); --------
Wow. Only slightly more moronic than a certain library that
typedefs each of the standard C types to a similar name beginning
with "g", though.
Which standard (the standard for whichever version of the language the
library is written in) types would those be?
Harald van Dijk <tr*****@gmail.comwrites:
Ben Pfaff wrote:
>dj******@csclub.uwaterloo.ca (Dave Vandervies) writes:
>>Seen in another place: -------- typedef void my_lib_void; my_lib_void my_lib_func(my_lib_void); --------
Wow. Only slightly more moronic than a certain library that typedefs each of the standard C types to a similar name beginning with "g", though.
Which standard (the standard for whichever version of the language the
library is written in) types would those be?
GTK does something similar. And for very good reasons. Nothing "moronic"
about it at all.
Richard wrote:
Harald van Dijk <tr*****@gmail.comwrites:
Ben Pfaff wrote:
dj******@csclub.uwaterloo.ca (Dave Vandervies) writes:
Seen in another place: -------- typedef void my_lib_void; my_lib_void my_lib_func(my_lib_void); --------
Wow. Only slightly more moronic than a certain library that
typedefs each of the standard C types to a similar name beginning
with "g", though.
Which standard (the standard for whichever version of the language the
library is written in) types would those be?
GTK does something similar. And for very good reasons. Nothing "moronic"
about it at all.
The Windows API is an infamous example of this too.
Ben Pfaff wrote On 07/10/07 11:04,:
dj******@csclub.uwaterloo.ca (Dave Vandervies) writes:
>>Seen in another place: -------- typedef void my_lib_void; my_lib_void my_lib_func(my_lib_void); --------
Wow. Only slightly more moronic than a certain library that
typedefs each of the standard C types to a similar name beginning
with "g", though.
How old is the code? Might it have been an attempt
to sneak void past a pre-Standard compiler that didn't
have it? On an old compiler, you'd typedef my_lib_void
to something "harmless" like int ...
But then, a compiler lacking void probably didn't
understand prototypes, either. So maybe it's merely
moronic. "Never attribute to malice that which can be
adequately explained by stupidity."
-- Er*********@sun.com
Richard <rg****@gmail.comwrites:
Harald van Dijk <tr*****@gmail.comwrites:
>Ben Pfaff wrote:
>>dj******@csclub.uwaterloo.ca (Dave Vandervies) writes:
Seen in another place: -------- typedef void my_lib_void; my_lib_void my_lib_func(my_lib_void); --------
Wow. Only slightly more moronic than a certain library that typedefs each of the standard C types to a similar name beginning with "g", though.
Which standard (the standard for whichever version of the language the library is written in) types would those be?
GTK does something similar. And for very good reasons. Nothing "moronic"
about it at all.
Actually I take that back since they do more than add a "g" or whatever
: they have their own types typedef'd back to the core C ones.
santosh <sa*********@gmail.comwrites:
Richard wrote:
Ben Pfaff wrote: Only slightly more moronic than a certain library that typedefs each of the standard C types to a similar name beginning with "g", though.
GTK does something similar. And for very good reasons. Nothing "moronic" about it at all.
What are these "very good reasons"?
--
Ben Pfaff http://benpfaff.org
In article <11**********************@r34g2000hsd.googlegroups .com>,
sumedh <ex**********@gmail.comwrote:
>but at same time if c code int main() {
typedef void my_lib_void;
printf("Hello void %d",sizeof(my_lib_void));
system("PAUSE");
return 0; } it works showing sizeof(my_lib_void) as 1 Can anyone explain why?
Because you are using gcc without the various options that would
flag the use of non-portable gcc extensions.
--
If you lie to the compiler, it will get its revenge. -- Henry Spencer
"santosh" <sa*********@gmail.comwrote in message
news:11*********************@d30g2000prg.googlegro ups.com...
Richard wrote:
Harald van D?k <tr*****@gmail.comwrites:
Ben Pfaff wrote:
dj******@csclub.uwaterloo.ca (Dave Vandervies) writes:
Seen in another place: -------- typedef void my_lib_void; my_lib_void my_lib_func(my_lib_void); --------
Wow. Only slightly more moronic than a certain library that
typedefs each of the standard C types to a similar name beginning
with "g", though.
Which standard (the standard for whichever version of the language the
library is written in) types would those be?
GTK does something similar. And for very good reasons. Nothing "moronic"
about it at all.
The Windows API is an infamous example of this too.
Arguably, Windows has produced a more consistent interface over the
years than many *nix implementions. But it is outside the realm of clc.
Ben Pfaff wrote:
santosh <sa*********@gmail.comwrites:
>Richard wrote:
>Ben Pfaff wrote: Only slightly more moronic than a certain library that typedefs each of the standard C types to a similar name beginning with "g", though.
GTK does something similar. And for very good reasons. Nothing "moronic" about it at all.
What are these "very good reasons"?
GLib's typedefs (the ones relevant to your message) are either 1) because
standard C90 doesn't provide a type with the meaning GLib needs, or 2) for
consistency with the types defined for reason 1.
"Barry" <ba****@nullhighstream.netwrites:
"santosh" <sa*********@gmail.comwrote in message
news:11*********************@d30g2000prg.googlegro ups.com...
Richard wrote:
>Harald van D?k <tr*****@gmail.comwrites:
Ben Pfaff wrote: dj******@csclub.uwaterloo.ca (Dave Vandervies) writes:
Seen in another place: -------- typedef void my_lib_void; my_lib_void my_lib_func(my_lib_void); --------
Wow. Only slightly more moronic than a certain library that typedefs each of the standard C types to a similar name beginning with "g", though.
Which standard (the standard for whichever version of the language the
library is written in) types would those be?
GTK does something similar. And for very good reasons. Nothing "moronic" about it at all.
The Windows API is an infamous example of this too.
Arguably, Windows has produced a more consistent interface over the
years than many *nix implementions. But it is outside the realm of clc.
It is in the realms of this thread and the naming of data types.
Harald van Dijk <tr*****@gmail.comwrites:
Ben Pfaff wrote:
>santosh <sa*********@gmail.comwrites:
>>Richard wrote: Ben Pfaff wrote: Only slightly more moronic than a certain library that typedefs each of the standard C types to a similar name beginning with "g", though.
GTK does something similar. And for very good reasons. Nothing "moronic" about it at all.
What are these "very good reasons"?
GLib's typedefs (the ones relevant to your message) are either 1) because
standard C90 doesn't provide a type with the meaning GLib needs, or 2) for
consistency with the types defined for reason 1.
And cross platform compilation where the "basic" types *might* differ ....
Harald van Dijk <tr*****@gmail.comwrites:
Ben Pfaff wrote:
>santosh <sa*********@gmail.comwrites:
>>Richard wrote: Ben Pfaff wrote: Only slightly more moronic than a certain library that typedefs each of the standard C types to a similar name beginning with "g", though.
GTK does something similar. And for very good reasons. Nothing "moronic" about it at all.
What are these "very good reasons"?
GLib's typedefs (the ones relevant to your message) are either 1) because
standard C90 doesn't provide a type with the meaning GLib needs, or 2) for
consistency with the types defined for reason 1.
You are saying that standard C90 doesn't provide, for example, a
type with the meaning of "gint", which is typedefed to int? The
same question can be applied to gchar, gshort, glong, gfloat,
gdouble, and possibly more.
--
char a[]="\n .CJacehknorstu";int putchar(int);int main(void){unsigned long b[]
={0x67dffdff,0x9aa9aa6a,0xa77ffda9,0x7da6aa6a,0xa6 7f6aaa,0xaa9aa9f6,0x11f6},*p
=b,i=24;for(;p+=!*p;*p/=4)switch(0[p]&3)case 0:{return 0;for(p--;i--;i--)case+
2:{i++;if(i)break;else default:continue;if(0)case 1:putchar(a[i&15]);break;}}}
Ben Pfaff <bl*@cs.stanford.eduwrites:
Harald van Dijk <tr*****@gmail.comwrites:
>Ben Pfaff wrote:
>>santosh <sa*********@gmail.comwrites: Richard wrote: Ben Pfaff wrote: Only slightly more moronic than a certain library that typedefs each of the standard C types to a similar name beginning with "g", though. > GTK does something similar. And for very good reasons. Nothing "moronic" about it at all.
What are these "very good reasons"?
GLib's typedefs (the ones relevant to your message) are either 1) because standard C90 doesn't provide a type with the meaning GLib needs, or 2) for consistency with the types defined for reason 1.
You are saying that standard C90 doesn't provide, for example, a
type with the meaning of "gint", which is typedefed to int? The
same question can be applied to gchar, gshort, glong, gfloat,
gdouble, and possibly more.
I think that GLib provides a number of typedefes for types that may or
may not be provided by the C implementation (gboolean, gssize); it
also provides typedefs for the predefined types for the sake of
consistency.
This means that, for example, a programmer using GLib doesn't have to
remember that size_t is standard C, bool is standard only in C99, and
ssize_t is not in any C standard.
Personally, I find the idea of extending this to "gint" and "gchar" to
be a bit much, but in terms of consistency it's not entirely absurd.
(I wonder why they have gchar and guchar but not gschar, but that's a
GLib question, not a C question.)
See <http://developer.gnome.org/doc/API/2.0/glib/glib-Basic-Types.html>.
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
sumedh wrote:
>
I tried running following c++ code
#include<stdio.h>
#include<iostream>
using namespace std;
Which is definitely not C code. So what is it doing in c.l.c?
--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
cbfalconer at maineline dot net
--
Posted via a free Usenet account from http://www.teranews.com
Ben Pfaff wrote:
Harald van Dijk <tr*****@gmail.comwrites:
>Ben Pfaff wrote:
>>santosh <sa*********@gmail.comwrites:
Richard wrote: Ben Pfaff wrote: Only slightly more moronic than a certain library that typedefs each of the standard C types to a similar name beginning with "g", though. > GTK does something similar. And for very good reasons. Nothing "moronic" about it at all.
What are these "very good reasons"?
GLib's typedefs (the ones relevant to your message) are either 1) because standard C90 doesn't provide a type with the meaning GLib needs, or 2) for consistency with the types defined for reason 1.
You are saying that standard C90 doesn't provide, for example, a
type with the meaning of "gint", which is typedefed to int? The
same question can be applied to gchar, gshort, glong, gfloat,
gdouble, and possibly more.
No, that's not what I said or meant. Those types are defined for the second
reason: consistency with the other types defined by GLib that aren't
available in standard C90. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: CMAR |
last post by:
I have the following markup. The problem is that the browser, e.g., IE6,
inserts several lines of blank space between the <div> and the following
table. Is there a way to minimize that vertical...
|
by: Daniel Tan |
last post by:
Are there anyway to copy rows of records from one query to another
query and then hide the records in source query ? Pls advise. Thanks.
Regards,
Daniel
|
by: Rooksarii |
last post by:
Hello folks,
Let me first apologize for any impropper terminology I may use as I am
presently trying to broaden my Office knowledge by diving into Access
head on.
My specific problem is this....
|
by: kmnotes04 |
last post by:
Is it possible to link one drop-down box to another? For example, if a
name is chosen from a drop-down list, can another drop-down list then
automatically display the person's office as a result of...
|
by: Kay |
last post by:
Hello,
I have two list boxes on my form, one initially displays with items and the
other displays blank, by clicking a button, it is possible to move items
from one box to another and vice a...
|
by: qwerty |
last post by:
I´m new to ASP.Net. My workmate has some experience with it.
He claimed that in ASP.Net working with frames is much simpler than it
was ASP. I asked explanation but he couldn't give me such. (a...
|
by: Eric_Dexter |
last post by:
def simplecsdtoorc(filename):
file = open(filename,"r")
alllines = file.read_until("</CsInstruments>")
pattern1 = re.compile("</")
orcfilename = filename + "orc"
for line in alllines:
if not...
|
by: Pavel Maly |
last post by:
Hi,
how do I access values in an ArrayList which is a part of another ArrayList? I know I can define
a class and then it is quite simple, but this is just an auxiliary application to compute some...
|
by: zman77 |
last post by:
EDIT: -- forgot to mention... I am using Visual Studio 2005, on Win XP, on an intel machine
Hi.
This is my first post, though I've "lurked" for a while because I find these forums very helpful....
|
by: fish919 |
last post by:
Hello All,
I am creating a date base in access. I want to create a dropdown list box that is connected to another dropdown list box.
You start with a dropdown list that has 5 choices and each of...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |