[Search for users]
[Overall Top Noters]
[List of all Conferences]
[Download this site]
Title: | C++ |
Notice: | Read 1.* and use keywords (e.g. SHOW KEY/FULL KIT_CXX_VAX_VMS) |
Moderator: | DECCXX::AMARTIN |
|
Created: | Fri Nov 06 1987 |
Last Modified: | Thu Jun 05 1997 |
Last Successful Update: | Fri Jun 06 1997 |
Number of topics: | 3604 |
Total number of notes: | 18242 |
3495.0. "uswitch() function appears to nave no c++ prototype." by RDGENG::CHAMBERLIN (Danger! Do not Reverse Polarity) Mon Mar 17 1997 06:17
The uswitch () function example given in the man page doesn't compile under c++
(DEC C++ V5.5-004, Digital Unix 44.0A). The normal C compiler accepts it OK.
watfor> cat uswitch.cc
#include <stdio.h>
#include <sys/types.h>
#include <sys/uswitch.h>
#include <string.h>
main()
{
size_t retval;
long uswitch_val;
uswitch_val = uswitch(USC_GET,0);
printf ("uswitch_val: %x\n", uswitch_val);
uswitch(USC_SET, uswitch_val | USW_NULLP);
uswitch_val = uswitch(USC_GET,0);
printf ("uswitch_val: %x\n", uswitch_val);
retval = strlen(NULL);
printf ("retval: %x\n", retval);
}
watfor> cxx -o usw usw.cc
cxx: Error: usw.cc, line 12: In this statement, "uswitch" is not declared.
uswitch_val = uswitch(USC_GET,0);
------------------^
cxx: Error: usw.cc, line 14: In this statement, "uswitch" is not declared.
uswitch(USC_SET, uswitch_val | USW_NULLP);
----^
cxx: Error: usw.cc, line 15: In this statement, "uswitch" is not declared.
uswitch_val = uswitch(USC_GET,0);
------------------^
If I include an external declaration of uswitch after the #includes.....
extern "C"
long uswitch(long, long);
Then it compiles and runs OK.
Not sure if this as this a c++ problem, a Unix problem or am I missing something?
Thanks,
Ian Chamberlin,
Software Partner Eng.
T.R | Title | User | Personal Name | Date | Lines |
---|
3495.1 | | MOIRA::FAIMAN | Wandrer, du M�der, du bist zu Haus | Mon Mar 17 1997 09:02 | 5 |
| The uswitch.h header defined a bunch of constants, but it doesn't define the
uswitch function. The C compiler doesn't care if you call an unprototyped
function, but C++ requires prototypes.
-Neil
|
3495.2 | I cross-posted this to Digital UNIX notes conference | DECC::J_WARD | | Mon Mar 17 1997 10:00 | 3 |
|
This is now posted as note 9201 in the Digital Unix notes
conference.
|
3495.3 | QAR it! | DECC::SULLIVAN | Jeff Sullivan | Mon Mar 17 1997 11:53 | 34 |
| This should be reported as an OSF_QAR.
Login to GORGE or use http://webster.zk3.dec.com/webqar
(if you need help, let me know).
This is still a problem in Steel BL8 and is also a problem with DEC C:
% cc t.c -w0
cc: Info: t.c, line 12: In this statement, the identifier "uswitch" is
implicitly declared as a function.
uswitch_val = uswitch(USC_GET,0);
------------------^
% cat t.c
#include <stdio.h>
#include <sys/types.h>
#include <sys/uswitch.h>
#include <string.h>
main()
{
size_t retval;
long uswitch_val;
uswitch_val = uswitch(USC_GET,0);
printf ("uswitch_val: %x\n", uswitch_val);
uswitch(USC_SET, uswitch_val | USW_NULLP);
uswitch_val = uswitch(USC_GET,0);
printf ("uswitch_val: %x\n", uswitch_val);
retval = strlen(NULL);
printf ("retval: %x\n", retval);
}
-Jeff
|