[Search for users]
[Overall Top Noters]
[List of all Conferences]
[Download this site]
| Title: | DIGITAL UNIX (FORMERLY KNOWN AS DEC OSF/1) | 
| Notice: | Welcome to the Digital UNIX Conference | 
| Moderator: | SMURF::DENHAM | 
|  | 
| Created: | Thu Mar 16 1995 | 
| Last Modified: | Fri Jun 06 1997 | 
| Last Successful Update: | Fri Jun 06 1997 | 
| Number of topics: | 10068 | 
| Total number of notes: | 35879 | 
9201.0. "uswitch() prototype missing from uswitch.h header" by DECC::J_WARD () Mon Mar 17 1997 09:58
In C_PLUS_PLUS note 3495, Ian Chamberlin reports that the
uswitch() prototype is missing from the sys/uswitch.h header,
causing C++ users to have to declare their own.
Here is the note:
        <<< TURRIS::DISK$NOTES_PACK:[NOTES$LIBRARY]C_PLUS_PLUS.NOTE;2 >>>
                                    -< C++ >-
================================================================================
Note 3495.0   uswitch() function appears to nave no c++ prototype.       1 reply
RDGENG::CHAMBERLIN "Danger! Do not Reverse Polarity"  51 lines  17-MAR-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 | 
|---|
| 9201.1 | QAR it! | DECC::SULLIVAN | Jeff Sullivan | Mon Mar 17 1997 11:49 | 32 | 
|  | Thsi should be reported as an OSF_QAR.
The problem still exists in Steel BL8.
%  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
 | 
| 9201.2 | QAR 52043 in OSF_QAR | RDGENG::CHAMBERLIN | Danger! Do not Reverse Polarity | Tue Mar 18 1997 04:40 | 0 |