delorie.com/djgpp/bugs/show.cgi   search  
Bug 000389

When Created: 07/26/2007 10:52:15
Against DJGPP version: 2.03
By whom: al0341@alunos.dq.fct.unl.pt
Abstract: Program compiles and runs even if I don't include needed libraries with DJGPP v4.0
I have the following program below:


#include <ctime>
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

// Function prototypes
unsigned int Stopwatch (const char *cmdline);

int main (short n_arg, char *arg[])
{
    short err_level = 1;
    if (n_arg < 2)
        cout << "----------------------------------\n"
             << "Stpwatch Command - Version 1.1\n"
             << "Copyright (c) 2007 Samuel Louren‡o\n"
             << "----------------------------------\n"
             << "Stpwatch comes with ABSOLUTELY NO WARRANTY. This is free software and you are\n"
             << "welcome to distribute it under the terms of the GNU General Public License.\n"
             << "Open \"COPYING.TXT\" to read the license.\n\n"
             << "Usage: stpwatch command [command_arguments]" << endl;
    else
    {
        string cmd_line = string (arg[1]);
        for (int i = 2; i < n_arg; i ++)
        {
            cmd_line += " " + string (arg[i]);
        }
        cout << fixed << setprecision (3)
             << "Executing command...\n"
             << "===============================================================================" << endl;
        int ticks = Stopwatch (cmd_line.c_str ());
        cout << "\n===============================================================================\n"
             << "Elapsed time: " << ticks << " clock ticks\n"
             << "              " << 1.0 * ticks / CLOCKS_PER_SEC << " seconds" << " (at " << CLOCKS_PER_SEC << " clock ticks per second)" << endl;
        err_level = 0;
    }
    return err_level; 
}

unsigned int Stopwatch (const char *cmd_line)
{
    unsigned int initial_tm = clock ();
    system (cmd_line);
    return (clock () - initial_tm);
}


However, if I take off the include to <string> or to <ctime>, the program compiles as if <string> or <ctime> were sucessfully included, and also runs correctly. Of course this is wrong, how can a program be compiled if I didn't included the needed libraries? The program should emit errors.

Note added: 07/27/2007 09:28:33
By whom: dj@delorie.com
First off, there's no such thing as DJGPP 4.0.  The last unreleased version is 2.04.  Perhaps you meant gcc 4.0?

Second, this isn't a "bug" in djgpp's itself, as you're complaining about the C++ libraries, which are part of the gcc package.  You may get more help from the gcc-help mailing list.

Closed on 07/27/2007 09:29:49: report is about libstdc++, not djgpp itself.
By whom: dj@delorie.com



  webmaster     delorie software   privacy  
  Copyright © 2010   by DJ Delorie     Updated Jul 2010