Click here to Skip to main content
15,441,629 members
Home / Discussions / Linux Programming
   

Linux Programming

 
GeneralRe: SOLVED Re: Can "cast looses precision " error be optioned out ? Pin
Vaclav_3-Mar-20 13:47
MemberVaclav_3-Mar-20 13:47 
QuestionBluetooth socket failures Pin
Vaclav_28-Feb-20 5:43
MemberVaclav_28-Feb-20 5:43 
AnswerRe: Bluetooth socket failures Pin
Richard MacCutchan28-Feb-20 6:32
mveRichard MacCutchan28-Feb-20 6:32 
GeneralRe: Bluetooth socket failures Pin
Vaclav_28-Feb-20 7:12
MemberVaclav_28-Feb-20 7:12 
GeneralRe: Bluetooth socket failures Pin
k505429-Feb-20 6:14
mvek505429-Feb-20 6:14 
GeneralRe: Bluetooth socket failures Pin
Vaclav_29-Feb-20 8:27
MemberVaclav_29-Feb-20 8:27 
GeneralRe: Bluetooth socket failures Pin
Richard MacCutchan29-Feb-20 21:19
mveRichard MacCutchan29-Feb-20 21:19 
GeneralRe: Bluetooth socket failures Pin
Vaclav_1-Mar-20 4:02
MemberVaclav_1-Mar-20 4:02 
perror(3) - Linux manual page[^]


Add a direct quote from man

When a system call fails, it usually returns -1 and sets the variable
       errno to a value describing what went wrong.  (These values can be
       found in <errno.h>.)  Many library functions do likewise.  The
       function perror() serves to translate this error code into human-
       readable form.  Note that errno is undefined after a successful
       system call or library function call: this call may well change this
       variable, even though it succeeds, for example because it internally
       used some other library function that failed.  Thus, if a failing
       call is not immediately followed by a call to perror(), the value of
       errno should be saved.



And I am not the only one using perror wrong. Take this gem
I have commented out here just to show the original code.
This "example" shows why some coders do not check the call result.




C++
	errcode = getaddrinfo("z_desktop", NULL, &hints, &res);
	//perror("STATE getaddrinfo");
	if (errcode != 0) {           // call returns "-errors " 
		//cout <<"errno " << dec << errno << endl;
		perror("STATE getaddrinfo");     
// perror prints "Success" !  getaddrinfo does not sets errno ! 
		//cout << " errcode (?) " << dec << errcode << endl;
		//cout << "hints.ai_addr " << dec <<  hints.ai_addr << endl;
		//cout <<"hints.ai_family  " << hints.ai_family << endl;
		return -1;
	}

GeneralRe: Bluetooth socket failures Pin
Vaclav_28-Feb-20 8:32
MemberVaclav_28-Feb-20 8:32 
QuestionRunning console apps on windows 7 Pin
Calin Cali23-Feb-20 20:07
MemberCalin Cali23-Feb-20 20:07 
AnswerRe: Running console apps on windows 7 Pin
Victor Nijegorodov23-Feb-20 20:45
MemberVictor Nijegorodov23-Feb-20 20:45 
GeneralRe: Running console apps on windows 7 Pin
Calin Cali23-Feb-20 21:22
MemberCalin Cali23-Feb-20 21:22 
AnswerRe: Running console apps on windows 7 Pin
Richard MacCutchan23-Feb-20 20:59
mveRichard MacCutchan23-Feb-20 20:59 
GeneralRe: Running console apps on windows 7 Pin
Calin Cali23-Feb-20 21:21
MemberCalin Cali23-Feb-20 21:21 
GeneralRe: Running console apps on windows 7 Pin
jsc4229-Feb-20 11:16
professionaljsc4229-Feb-20 11:16 
Questiongetting started with ASM, what compilers do you use? Pin
Calin Cali21-Feb-20 1:47
MemberCalin Cali21-Feb-20 1:47 
AnswerRe: getting started with ASM, what compilers do you use? Pin
Richard MacCutchan21-Feb-20 1:52
mveRichard MacCutchan21-Feb-20 1:52 
GeneralRe: getting started with ASM, what compilers do you use? Pin
Calin Cali21-Feb-20 2:40
MemberCalin Cali21-Feb-20 2:40 
GeneralRe: getting started with ASM, what compilers do you use? Pin
Richard MacCutchan21-Feb-20 3:54
mveRichard MacCutchan21-Feb-20 3:54 
GeneralRe: getting started with ASM, what compilers do you use? Pin
Calin Cali21-Feb-20 6:39
MemberCalin Cali21-Feb-20 6:39 
GeneralRe: getting started with ASM, what compilers do you use? Pin
Richard MacCutchan21-Feb-20 6:50
mveRichard MacCutchan21-Feb-20 6:50 
GeneralRe: getting started with ASM, what compilers do you use? Pin
Calin Cali21-Feb-20 7:04
MemberCalin Cali21-Feb-20 7:04 
QuestionCross compilation mystery Pin
fd97504-Feb-20 4:53
professionalfd97504-Feb-20 4:53 
GeneralRe: Cross compilation mystery Pin
Richard MacCutchan4-Feb-20 6:14
mveRichard MacCutchan4-Feb-20 6:14 
GeneralRe: Cross compilation mystery Pin
k50544-Feb-20 6:53
mvek50544-Feb-20 6:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.