Thread View: comp.std.c++
1 messages
1 total messages
Started by Alexander Krotoff
Mon, 29 Jan 1996 19:15
Appendix C (Compatibility)
Author: Alexander Krotoff
Date: Mon, 29 Jan 1996 19:15
Date: Mon, 29 Jan 1996 19:15
116 lines
3303 bytes
3303 bytes
Hello c++ gurus,
I have some remarks on the Appendix C (Compatibility).
------------------------------------------------------------------------
C.1.1 C++ features available in 1985
13A pointer to function can be assigned to a void*; _conv.ptr_.
Is it correct ?
4.10 Pointer conversions says:
2 An rvalue of type "pointer to cv T," where T is an object
type, can be converted to an rvalue of type "pointer to
cv void."
The function type is not object type.
------------------------------------------------------------------------
C.1.2 C++ features added since 1985
Did you forgot namespaces in this list ?
========================================================================
Additional differences ISO C/C++:
------------------------------------------------------------------------
In C conversion to pointer types and null pointer constant may be used
in the constant expression.
In C++ they cannot be used in the context of integral constant expression.
ANSI C 3.4
WP C++ expr.const
Example:
#include <stddef.h>
struct A {
int a;
int b;
};
void f()
{
int i;
switch (i) {
case 1:
case offsetof (struct A, b):
i--;
}
}
Here I assume semi-standard definition of offsetof macro.
------------------------------------------------------------------------
In C struct member can have the same name, as struct itself.
In C++ it do not.
Example:
struct a { // vadid C
int a; // invalid C++
};
------------------------------------------------------------------------
According to Extensions to ANSI C A.6.5.4 C compiler may use additional
scope rules for external objects.
There is no such rule in C++.
Of course, this rule is not in the ANSI C itself.
Example1:
void f(void)
{
extern int a[];
}
void g()
{
int *pi = a+1; // Valid C, invalid c++.
}
Example2:
void f(void)
{
extern void g(void);
}
void h(void)
{
void (*p)(void) = g;
}
------------------------------------------------------------------------
In C and C++ syntax for empty enum is differnent.
In C enumerator list enclosed in `{}' is not allowed to be empty.
In C++ empty enumerator list is allowed, but '{}'
must be present.
C++ WP dcl.enum
ANSI C 3.5.2.2
Example:
enum a; // valid C, invalid C++.
enum {}; // valid C++, invalid C.
------------------------------------------------------------------------
--
Alexander N. Krotoff krotoff@such.srcc.msu.su
Research Computer Center tel: +7(095)939-2638
Moscow State University fax: +7(095)939-4430
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads