[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::c_plus_plus

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.RTitleUserPersonal
Name
DateLines
3495.1MOIRA::FAIMANWandrer, du M�der, du bist zu HausMon Mar 17 1997 09:025
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.2I cross-posted this to Digital UNIX notes conferenceDECC::J_WARDMon Mar 17 1997 10:003
This is now posted as note 9201 in the Digital Unix notes
conference.
3495.3QAR it!DECC::SULLIVANJeff SullivanMon Mar 17 1997 11:5334
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