Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8051475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:18:44+00:00 2026-06-05T07:18:44+00:00

I have stumbled on a compile error that makes no sense to me. So,

  • 0

I have stumbled on a compile error that makes no sense to me. So, of course, I turn to StackOverflow…..

System

Linux (Ubuntu 10.04 32 bit, gcc (Ubuntu 4.4.3-4ubuntu5.1) 4.4.3, Eclipse Indigo

** Question **

Obvious question, of course; What is gcc complaining about?

Background

I have a class, ThreadTime, coded in its own cpp and h files, ThreadTime.cpp and .h and inside its own namespace THREAD_TIME;

In main() I launch two threads, call then ThreadA and ThreadB, then go into an infinite loop that sleeps 2 seconds then checks to see if ThreadA and ThreadB are still running. in particular, if ThreadA has stopped, it gets restarted.

Each thread creates an associated ThreadTime object. In both of my threads there are loops. During each loop, the ThreadTimer get updated (in < 2 secs) so the main() loop can see that time is advancing in the threads.

As each ThreadTimer is created its address is added to a global vector, g_CthreadVector, of type std::vector<ThreadTime*>. g_CthreadVector is file global in ThreadType.cpp.

It’s probably best to just paste the whole class here. So…

ThreadTime.cpp

#include "ThreadTime.

namespace THREAD_TIME
{
   std::vector<ThreadTime*>      g_CthreadVector; // threads to kill and monitor

   ThreadTime::ThreadTime(thread_t* a, time_t b, void* c)
     : m_pthread(a), m_time(b), m_lasttime(b-2), m_function(c), m_terminate (FALSE)
   {
      m_name = "a ThreadTime object";
      g_CthreadVector.push_back( this );
   }

   ThreadTime::~ThreadTime()
   {
      std::vector<ThreadTime*>::iterator     it       (GetIterator());
      if ( it != g_CthreadVector.end() )
         g_CthreadVector.erase( it );
   }

   void     ThreadTime::UpdateTime( void )
   {
      m_lasttime = m_time;                                              // save the time to lasttime
      m_time = time(NULL);                                              // store the current time
      if ( m_lasttime == m_time )                                       // safety valve keep m_time
         m_lasttime--;                                                  //     ahead of m_lasttime
   }

   //---------------------------------------------------------
   // did time get advanced?
   //---------------------------------------------------------
   bool     ThreadTime::TimeAdvanced( void )
   {
      if ( m_lasttime < m_time )       return TRUE;
      else                             return FALSE;
   }

   void     ThreadTime::print( void )
   {
      std::vector<ThreadTime*>::iterator      tt_it   (GetIterator());
      std::vector<ThreadTime*>::iterator      it      (g_CthreadVector.end());

         for ( it = g_CthreadVector.begin(); it < g_CthreadVector.end(); it++ )
         {
            if ( tt_it == it )
               std::cout << "  ################### CURRENT OBJECT ###################### " << std::endl;
            else
               std::cout << "  $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ " << std::endl;

            std::cout << "  ThreadTime Object: " << (*it)->getName()    << std::endl
                      << "         thread ptr: " << (*it)->m_pthread    << std::endl
                      << "               time: " << (*it)->m_time       << std::endl
                      << "           lasttime: " << (*it)->m_lasttime   << std::endl
                      << "       function ptr: " << (*it)->m_function   << std::endl
                      << "          terminate: " << (*it)->m_terminate  << std::endl;
         }
         std::cout << "  $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ " << std::endl;
   }     // for ( it ... )

   std::vector<ThreadTime*>::iterator  ThreadTime::GetIterator( void )
   {
      std::vector<ThreadTime*>::iterator      it      (g_CthreadVector.end());

      for ( it = g_CthreadVector.begin(); it < g_CthreadVector.end(); it++)
      {
         if ( (*it)->m_pthread == m_pthread )
            break;
      }

      return it;
   }

} /* namespace THREAD_TIME */

ThreadTime.h

#ifndef THREADTIME_H_
   #define THREADTIME_H_

   #include "platform.h"
   #include "opsys_common.h"
   #include "NAS_Thread.h"


   namespace THREAD_TIME
   {
      class ThreadTime;

      class ThreadTime
      {
         public:
            std::string       getName() const                  { return m_name; }
            void              setName(std::string name)        { m_name = name; }

            ThreadTime(thread_t* a, time_t b, void* c);
            ~ThreadTime();
            void     UpdateTime( void );
            bool     TimeAdvanced( void );
            void     print( void );

         private:
            std::vector<ThreadTime*>::iterator       GetIterator( void );

            std::string    m_name;
            thread_t*      m_pthread;
            time_t         m_time;
            time_t         m_lasttime;
            void*          m_function;
            bool           m_terminate;
   };

} /* namespace THREAD_TIME */

#endif /* THREADTIME_H_ */

And finally, here are the error messages:

expected ‘;’ before ‘<’ token ThreadTime.h line 37

invalid use of ‘::’ ThreadTime.h Line 37

ISO C++ forbids declaration of ‘vector’ with no type ThreadTime.h line 37

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T07:18:45+00:00Added an answer on June 5, 2026 at 7:18 am

    There is no declaration of std::vector in scope for your class. You need a #include <vector>.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am debugging some old ASP code and have stumbled upon the following error:
I have stumbled upon a strange behavior that I don't understand. I have to
I stumbled upon an interesting error that I've never seen before, and can't explain
I have stumbled across some code that is adding strings to a List but
I've just stumbled across this and I'm a bit puzzled. I have an out-of-the-box
I have stumbled into the :not() selector on day 12 of Jquery. I would
I have stumbled upon the following F77 yacc grammar: http://yaxx.cvs.sourceforge.net/viewvc/yaxx/yaxx/fortran/fortran.y?revision=1.3&view=markup . How can I
I'm quite new to hibernate and have stumbled on this problem, which I can't
I am learning about LLDP protocol and have stumbled across terms chassis ID and
I have been playing about with canvas, but have stumbled across a problem. When

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.