Visual Studio 2019: Identifier "time_t" undefined

Caffeinated Pizza 1 Reputation point
2021-02-25T06:02:26.027+00:00

Very simple header file:

#ifndef _PTIME_H
#define _PTIME_H
#pragma once

#include <ctime>


class PTime
{
public:
 PTime();
 ~PTime();

private:
 time_t now;
};

#endif

Is giving me an error Identifier "time_t" is undefined. How is this possible? I included the proper header file. Why is Visual Studio 2019 complaining about time_t?

Developer technologies | C++
{count} votes

2 answers

Sort by: Most helpful
  1. Guido Franzke 2,191 Reputation points
    2021-02-25T06:53:01.28+00:00

    Hello,
    try to include <time.h> .
    Regards, Guido

    1 person found this answer helpful.

  2. WayneAKing 4,931 Reputation points
    2021-02-25T11:29:51.977+00:00

    Are you getting a compile error, or an Intellisense error?

    If the latter, try using the option to rescan the solution
    found under the Project menu.

    Sometimes when code is added bit by bit Intellisense does
    not pick up all of the changes automatically. Doing a Rescan
    forces it to process all of the code in its current state.

    • Wayne
    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.