posix.error.h.xml 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <chapter xml:id="posix.error.h">
  2. <title><tt>__vic/posix/error.h</tt></title>
  3. <p>POSIX-specific error handling tools.</p>
  4. <chapter xml:id="posix--is_EAGAIN">
  5. <title><tt>posix::is_EAGAIN()</tt>, <tt>posix::is_ENOENT()</tt></title>
  6. <code-block lang="C++">
  7. namespace posix {
  8. bool is_EAGAIN(int err_no);
  9. bool is_ENOENT(int err_no);
  10. #define __VIC_CASE_EAGAIN <nt>case &lt;val1>: case &lt;val2>: ...</nt>
  11. #define __VIC_CASE_ENOENT <nt>case &lt;val1>: case &lt;val2>: ...</nt>
  12. }
  13. </code-block>
  14. <p>The first function checks if the code is either <tt>EAGAIN</tt> or
  15. <tt>EWOULDBLOCK</tt>. It works regardless of these codes have the same numeric
  16. value or not on the current platform.</p>
  17. <p>The second function checks if the error code is <tt>ENOENT</tt>,
  18. <tt>ESTALE</tt> or any other error code that means "file not found".</p>
  19. <p>The macros are meant to be used inside <tt>switch</tt>. They are expanded
  20. either to the single <tt>case</tt> with colon or to the set of <tt>case</tt>s,
  21. and have the same meaning as the corresponding functions.</p>
  22. <section><title>Example</title>
  23. <code-block lang="C++"><![CDATA[
  24. switch(errno)
  25. {
  26. __VIC_CASE_ENOENT
  27. std::cout << "No file found!\n"; break;
  28. case EPERM:
  29. ...
  30. }
  31. ]]></code-block>
  32. </section>
  33. </chapter>
  34. </chapter>