Click here to Skip to main content
15,845,829 members
Home / Discussions / Linux Programming
   

Linux Programming

 
GeneralRe: SOLVED Re: Can "cast looses precision " error be optioned out ? Pin
Vaclav_3-Mar-20 14:47
Vaclav_3-Mar-20 14:47 
QuestionBluetooth socket failures Pin
Vaclav_28-Feb-20 6:43
Vaclav_28-Feb-20 6:43 
AnswerRe: Bluetooth socket failures Pin
Richard MacCutchan28-Feb-20 7:32
mveRichard MacCutchan28-Feb-20 7:32 
GeneralRe: Bluetooth socket failures Pin
Vaclav_28-Feb-20 8:12
Vaclav_28-Feb-20 8:12 
GeneralRe: Bluetooth socket failures Pin
k505429-Feb-20 7:14
mvek505429-Feb-20 7:14 
GeneralRe: Bluetooth socket failures Pin
Vaclav_29-Feb-20 9:27
Vaclav_29-Feb-20 9:27 
GeneralRe: Bluetooth socket failures Pin
Richard MacCutchan29-Feb-20 22:19
mveRichard MacCutchan29-Feb-20 22:19 
GeneralRe: Bluetooth socket failures Pin
Vaclav_1-Mar-20 5:02
Vaclav_1-Mar-20 5: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 9:32
Vaclav_28-Feb-20 9:32 
QuestionRunning console apps on windows 7 Pin
Calin Negru23-Feb-20 21:07
Calin Negru23-Feb-20 21:07 
AnswerRe: Running console apps on windows 7 Pin
Victor Nijegorodov23-Feb-20 21:45
Victor Nijegorodov23-Feb-20 21:45 
GeneralRe: Running console apps on windows 7 Pin
Calin Negru23-Feb-20 22:22
Calin Negru23-Feb-20 22:22 
AnswerRe: Running console apps on windows 7 Pin
Richard MacCutchan23-Feb-20 21:59
mveRichard MacCutchan23-Feb-20 21:59 
GeneralRe: Running console apps on windows 7 Pin
Calin Negru23-Feb-20 22:21
Calin Negru23-Feb-20 22:21 
GeneralRe: Running console apps on windows 7 Pin
jsc4229-Feb-20 12:16
professionaljsc4229-Feb-20 12:16 
Questiongetting started with ASM, what compilers do you use? Pin
Calin Negru21-Feb-20 2:47
Calin Negru21-Feb-20 2:47 
AnswerRe: getting started with ASM, what compilers do you use? Pin
Richard MacCutchan21-Feb-20 2:52
mveRichard MacCutchan21-Feb-20 2:52 
GeneralRe: getting started with ASM, what compilers do you use? Pin
Calin Negru21-Feb-20 3:40
Calin Negru21-Feb-20 3:40 
GeneralRe: getting started with ASM, what compilers do you use? Pin
Richard MacCutchan21-Feb-20 4:54
mveRichard MacCutchan21-Feb-20 4:54 
GeneralRe: getting started with ASM, what compilers do you use? Pin
Calin Negru21-Feb-20 7:39
Calin Negru21-Feb-20 7:39 
GeneralRe: getting started with ASM, what compilers do you use? Pin
Richard MacCutchan21-Feb-20 7:50
mveRichard MacCutchan21-Feb-20 7:50 
GeneralRe: getting started with ASM, what compilers do you use? Pin
Calin Negru21-Feb-20 8:04
Calin Negru21-Feb-20 8:04 
QuestionCross compilation mystery Pin
fd97504-Feb-20 5:53
professionalfd97504-Feb-20 5:53 
GeneralRe: Cross compilation mystery Pin
Richard MacCutchan4-Feb-20 7:14
mveRichard MacCutchan4-Feb-20 7:14 
GeneralRe: Cross compilation mystery Pin
k50544-Feb-20 7:53
mvek50544-Feb-20 7: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.