Click here to Skip to main content
15,867,568 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Snooker Game programing using c Programing. Pin
jschell4-Apr-23 6:24
jschell4-Apr-23 6:24 
GeneralRe: Snooker Game programing using c Programing. Pin
Daniel Pfeffer4-Apr-23 7:40
professionalDaniel Pfeffer4-Apr-23 7:40 
SuggestionMessage Closed Pin
29-Mar-23 15:32
Member 1496877129-Mar-23 15:32 
GeneralRe: Socket or file descriptor ? Pin
k505429-Mar-23 17:18
mvek505429-Mar-23 17:18 
GeneralRe: Socket or file descriptor ? Pin
Richard MacCutchan29-Mar-23 21:38
mveRichard MacCutchan29-Mar-23 21:38 
GeneralRe: Socket or file descriptor ? Pin
jschell30-Mar-23 5:45
jschell30-Mar-23 5:45 
GeneralMessage Closed Pin
30-Mar-23 6:28
Member 1496877130-Mar-23 6:28 
GeneralRe: Socket or file descriptor - more questions ? Pin
k505430-Mar-23 9:31
mvek505430-Mar-23 9:31 
Unless you're hacking on glibc, you really shouldn't be digging around in the system include files.

Nevertheless, doing some googling around I learned this:
Terminal
k5054@localhost]$ cpp -include stdlib.h -dM /dev/null | grep -E 'define (THROW|LEAF)>'
#define __LEAF , __leaf
#define THROW __attribute ((nothrow __LEAF))
[k5054@localhost]$ 
That means that the __THROW notation adds the attributes nothrow and leaf to the definition of the function. You can read up on them here:Function Attributes - Using the GNU Compiler Collection (GCC)

Surely by now you know how to handle libc errors:
C++
#include <cerrno>
#include <cstring>

int ret = socket(foo, bar, baz); // socket() returns -1 on error and sets global var errno

if(ret == -1 ) {
   switch (errno) {
      case EACCES:
          // handle EACCES issue
          break;
      // etc.
      default:
          // print out the text associated with the error using strerror()
          std::cerr << "socket() returned error " << strerror(errno) << '\n';
     }
}

Note: It is perfectly possible for errno to be set by a system call, even when the system call is successful. That can happen when the system call itself makes another system call, which sets errno. I ran into this not so long ago with code like:
C++
errno = 0;
ret = somefn(blah, blah, blah);
if (errno) {
    // do stuff
}
In this case somefn() called otherfn() to do its work. otherfn() failed, setting errno in the process, and then somfn handled the error, and perhaps called anotherfn() which succeded, but did not set errno back to zero. Moral of the story: you need to check if your system call returned an error (normally -1, but not neccesarily), and then check the value of errno.
Keep Calm and Carry On

QuestionFind X,Y index into 2D array/matrix using an angle and number of cells Pin
imk12326-Mar-23 7:37
imk12326-Mar-23 7:37 
AnswerRe: Find X,Y index into 2D array/matrix using an angle and number of cells Pin
Mircea Neacsu26-Mar-23 8:04
Mircea Neacsu26-Mar-23 8:04 
AnswerRe: Find X,Y index into 2D array/matrix using an angle and number of cells Pin
Gerry Schmitz26-Mar-23 8:50
mveGerry Schmitz26-Mar-23 8:50 
QuestionWhat is the difference in C and C++ in terms of memory management ? Pin
Gulshan Negi20-Mar-23 22:57
professionalGulshan Negi20-Mar-23 22:57 
GeneralRe: What is the difference in C and C++ in terms of memory management ? Pin
Richard MacCutchan21-Mar-23 2:11
mveRichard MacCutchan21-Mar-23 2:11 
AnswerRe: What is the difference in C and C++ in terms of memory management ? Pin
jschell21-Mar-23 5:41
jschell21-Mar-23 5:41 
QuestionC language Pin
Pavani M18-Mar-23 5:24
Pavani M18-Mar-23 5:24 
AnswerRe: C language Pin
Richard MacCutchan18-Mar-23 6:53
mveRichard MacCutchan18-Mar-23 6:53 
AnswerRe: C language Pin
CPallini19-Mar-23 22:33
mveCPallini19-Mar-23 22:33 
QuestionMessage Closed Pin
5-Mar-23 5:33
Member 149687715-Mar-23 5:33 
AnswerRe: Reorganizing code Pin
Richard MacCutchan5-Mar-23 21:56
mveRichard MacCutchan5-Mar-23 21:56 
QuestionMessage Closed Pin
3-Mar-23 5:42
Member 149687713-Mar-23 5:42 
AnswerRe: How to implement variable amount of parameters? Pin
Mircea Neacsu3-Mar-23 6:10
Mircea Neacsu3-Mar-23 6:10 
AnswerRe: How to implement variable amount of parameters? Pin
k50543-Mar-23 6:18
mvek50543-Mar-23 6:18 
AnswerRe: How to implement variable amount of parameters? Pin
Richard MacCutchan3-Mar-23 21:57
mveRichard MacCutchan3-Mar-23 21:57 
AnswerRe: How to implement variable amount of parameters? Pin
jschell6-Mar-23 6:20
jschell6-Mar-23 6:20 
GeneralRe: How to implement variable amount of parameters? Pin
charlieg19-Mar-23 11:47
charlieg19-Mar-23 11:47 

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.