Configure script

dpanech
2004-06-16
2004-06-17
  • dpanech

    dpanech - 2004-06-16

    Hello,

    I've posted a patch that adds a configure script to timespan (tested with gcc 3.3 and gcc 2.95).

    Also, I've noticed a couple of portability problems (not fixed in the patch):
    * Missing "using" directives after #include'ing headers such as <cstring>. I think maybe a single "using namespace std" in the header file would be sufficient.
    * "unsigned long long" is not portable. However many systems have similar types -- uint64_t, unsigned __int64, etc. Maybe this should be detected and typedef'ed by configure, too.

    Regards,
    D.

     
    • John Bailey

      John Bailey - 2004-06-16

      Thanks for submitting the patch.  I do have two questions about your comment here, though.  What using statements do I need?  And should I wrap them in #ifdef's to detect the compiler(s) that require them?  I haven't received any warnings or errors with gcc 3.2.2 or 3.3.1 (both SuSE-compiled versions).  Also, I have started working to make timespan comaptible with the Visual Studio .NET 2002 and 2003 compilers, and the only errors I am receiving from them have to do with "unsigned long long" (VS.NET 2002) and the way I've done some function calls (VS.NET 2003).

      If you are interested in joining the project, let me know.

       
    • dpanech

      dpanech - 2004-06-17

      As per ANSI C++: all standard headers are supposed to declare everything inside the std:: namespace. So you could do the same thing you did with <iostream>:
        #include <cstring>
        using std::strlen;
        // etc.
        #include <ctime>
        using std::time_t;
        // etc.

      Its the same story with all "new-style" C library headers -- <cstdio>, <cstdlib>, etc.

      The problem is some compilers (Visual C++ v6) don't bother with the namespace in <c...> headers. I still think the easiest and safest thing to do is replace all using directives with a single one:

        #include <iostream>
        #include <fstream>
        #include <cstring>
        // ...
        using namespace std;

      This should work everywhere.

      Now, the reason your code compiles in gcc, is because its <cstring> et al #include's <string.h>, so you are really hitting the declarations from the .h header, which are in the global namespace. This is common, but not required by ANSI.

      Another thing, AFAIK declarations such as
        char *months[] = { "Jan", ... };
      ought to (must?) be written as
        const char *months[] = { "Jan", ... };
      This is different from C, where consts work differently (C++ is more strict). Generally, typeof (string-literals) is "const char *", not "char *" in C++. GCC doesn't complain about this, but I bet some compilers would.

      And yes, I would be interested in maintaining autoconf sources for your program.

      Thanks,
      D.

       
      • John Bailey

        John Bailey - 2004-06-17

        Thanks for your interest!  I've added you to the project.  You now have pretty much full access to the project.

         

Log in to post a comment.