EAStdC.html 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  5. <Title>EAStdC</title>
  6. <link type="text/css" rel="stylesheet" href="UTFDoc.css">
  7. <meta name="author" content="Paul Pedriana">
  8. </head>
  9. <body bgcolor="#FFFFFF">
  10. <h1>EAStdC</h1>
  11. <p>EAStdC is a package which implements a number of basic library facilities that are similar to those in the standard C library. This does not mean that its functionality is identical to the C standard library. It is an evolution and convergence of the rwstdc and UTFFoundation packages. </p>
  12. <p>The fundamental design characteristics of EAStdC are:</p>
  13. <ul>
  14. <li>The package has minimal dependencies: EABase and EAAssert.</li>
  15. <li>It consists of simple standalone functions and classes.</li>
  16. <li>Memory is not allocated by any of the functions or classes, excepts possibly under pathological conditions.</li>
  17. <li>There is no thread-safety. All thread safety must be coordinated at a higher level by the user. </li>
  18. <li>It does not implement localization functionality. Localization functionality is left to specialized libraries for that purpose.</li>
  19. <li>With few exceptions, both char8_t and char16_t string functionality are supported equivalently.</li>
  20. </ul>
  21. <h3> Should you use EAStdC functions that overlap with Standard C library functions?</h3>
  22. <p>A primary purpose of EAStdC is to provide a portable implementation of basic utility functions, many of which correspond the standard C library functions. Specifically: </p>
  23. <ul>
  24. <li> Provide a standardizes portable header file to #include. </li>
  25. <ul>
  26. <li> e.g. C libraries don&rsquo;t use the same name for headers, such as malloc.h, sys/types.h, memory.h, etc. </li>
  27. </ul>
  28. <li> Provide standardized function names. </li>
  29. <ul>
  30. <li> e.g. EAStdC has Vsnprintf, as opposed to VC++ having _vsnprintf but GCC having vsnprintf. </li>
  31. </ul>
  32. <li> Provide standardized function implementations. </li>
  33. <ul>
  34. <li> e.g. Sprintf/Scanf work the same in EAStdC, unlike most C libraries. </li>
  35. </ul>
  36. <li> Provide faster versions. </li>
  37. <ul>
  38. <li> e.g. Faster strlen, memcpy, special fast memcpy versions. EAStdC sprintf is much faster than stdc. </li>
  39. </ul>
  40. <li> Provide versions that don&rsquo;t exist in compiler-provided libraries. </li>
  41. <ul>
  42. <li> e.g. EAStdC has vsnprintf, whereas some C libraries don&rsquo;t. </li>
  43. </ul>
  44. <li> Lower memory requirements. </li>
  45. <ul>
  46. <li> Some stdc functions tend to bring in a lot of object code, often because of their locale requirements. </li>
  47. </ul>
  48. <li> Provides consistent standardized encoding. </li>
  49. <ul>
  50. <li> EAStdC uses UTF8 for char8_t and UCS2 for char16_t, whereas C libraries aren&rsquo;t consistent. wchar_t could be 8, 16, or 32 bit (we&rsquo;ve seen each of these). </li>
  51. </ul>
  52. <li> Provide auxiliary or &ldquo;better&rdquo; versions of functions. </li>
  53. <ul>
  54. <li> e.g. EAStdC&rsquo;s Random, DateTime. </li>
  55. </ul>
  56. <li> EAStdC has additional functionality that doesn&rsquo;t directly match something from the Standard C library. </li>
  57. <ul>
  58. <li> e.g. Stopwatch, Hash, FixedPoint. </li>
  59. </ul>
  60. </ul>
  61. <p> Primary downsides to EAStdC: </p>
  62. <ul>
  63. <li> It doesn&rsquo;t have localization support. You can&rsquo;t call setlocale() with it and have it change how it interprets &ldquo;.&rdquo; And &ldquo;,&rdquo; in numbers. You need to use the EALocale or EAText package for that, though EALocale and EAText do a better job than stdc does. </li>
  64. <li> EAStdC might have bugs that haven&rsquo;t been eradicated, while most stdc implementations are pretty good. </li>
  65. <li> Stdc has better documentation, though the EAStdC functions that are stdc equivalents usually have the same specification. </li>
  66. </ul>
  67. <p> In the case of overlap between stdc and EAStdC, I think the policy of what to use depends on your team conventions and your project requirements. Some notes: </p>
  68. <ul>
  69. <li> If you want to guarantee portability then you&rsquo;re better off using EAStdC. </li>
  70. <li> Some functions (e.g. strlen and memcpy) are basic enough that the stdc versions are usually fine. </li>
  71. <ul>
  72. <li> Except EAStdC&rsquo;s Strlen is faster than most stdc versions, and a surprising number of memcpy implementations for uncommon platforms are slow. </li>
  73. </ul>
  74. <li> If you think your code will need to build outside our codebase then maybe you should try to stick with stdc. </li>
  75. </ul>
  76. <hr>
  77. <p>&nbsp;</p>
  78. <p>&nbsp;</p>
  79. <p>&nbsp;</p>
  80. </body>
  81. </html>