Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. covert time_t ot LONG

covert time_t ot LONG

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++help
11 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S sach

    hi !! I am newbie in VC++. I am having problem coverting a time_t varible into LONG data type. as far as I know time_t is 64 bit int but I have no idea about LONG.. what is the safe way to do that??

    P Offline
    P Offline
    Programm3r
    wrote on last edited by
    #2

    what about type casting?

    Regards Programm3r

    S 1 Reply Last reply
    0
    • P Programm3r

      what about type casting?

      Regards Programm3r

      S Offline
      S Offline
      sach
      wrote on last edited by
      #3

      thx for the quick rpl! I did type casting!! The compiler agrees on that! But is it really safe!!! It should not break at run-time. Also how much byte does LONG takeS?? thx!!

      G T 2 Replies Last reply
      0
      • S sach

        thx for the quick rpl! I did type casting!! The compiler agrees on that! But is it really safe!!! It should not break at run-time. Also how much byte does LONG takeS?? thx!!

        G Offline
        G Offline
        Ganesh_T
        wrote on last edited by
        #4

        LONG is 4 bytes. time_t is now a 64-bit value (unless _USE_32BIT_TIME_T is defined).

        "A winner is not one who never fails...but the one who never quits"

        S 1 Reply Last reply
        0
        • G Ganesh_T

          LONG is 4 bytes. time_t is now a 64-bit value (unless _USE_32BIT_TIME_T is defined).

          "A winner is not one who never fails...but the one who never quits"

          S Offline
          S Offline
          sach
          wrote on last edited by
          #5

          i defined _USE_32BIT_TIME_T in the header file at the top!! I rebuild the solution. Still its showing time_t as type int_64 and size 8 bytes. where am I going wrong!

          1 Reply Last reply
          0
          • S sach

            thx for the quick rpl! I did type casting!! The compiler agrees on that! But is it really safe!!! It should not break at run-time. Also how much byte does LONG takeS?? thx!!

            T Offline
            T Offline
            toxcct
            wrote on last edited by
            #6

            sach!! wrote:

            Also how much byte does LONG takeS??

            write this to know : std::cout << "sizeof(LONG) = " << sizeof(LONG) << endl;


            TOXCCT >>> GEII power

            [VisualCalc 3.0  updated ][Flags Beginner's Guide  new! ]

            S 1 Reply Last reply
            0
            • T toxcct

              sach!! wrote:

              Also how much byte does LONG takeS??

              write this to know : std::cout << "sizeof(LONG) = " << sizeof(LONG) << endl;


              TOXCCT >>> GEII power

              [VisualCalc 3.0  updated ][Flags Beginner's Guide  new! ]

              S Offline
              S Offline
              sach
              wrote on last edited by
              #7

              Thx That is what i am doing to get the size!! I need to use 32bit time_t so i declered #define _USE_32BIT_TIME_T But its not making any diffence!! I am still getting 8 bytes as a size of time_t var.

              T 1 Reply Last reply
              0
              • S sach

                hi !! I am newbie in VC++. I am having problem coverting a time_t varible into LONG data type. as far as I know time_t is 64 bit int but I have no idea about LONG.. what is the safe way to do that??

                T Offline
                T Offline
                ThatsAlok
                wrote on last edited by
                #8

                sach!! wrote:

                am having problem coverting a time_t varible into LONG data type.

                my Question is WHY?

                "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You

                S 1 Reply Last reply
                0
                • T ThatsAlok

                  sach!! wrote:

                  am having problem coverting a time_t varible into LONG data type.

                  my Question is WHY?

                  "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                  cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You

                  S Offline
                  S Offline
                  sach
                  wrote on last edited by
                  #9

                  hi alok!! I am porting code from VC6 to VC8. I have many other function which r taking LONg as a parameter. If I can convert the time_t to LONG, that will save time n efforts to change all those function. Thats why! thx

                  1 Reply Last reply
                  0
                  • S sach

                    hi !! I am newbie in VC++. I am having problem coverting a time_t varible into LONG data type. as far as I know time_t is 64 bit int but I have no idea about LONG.. what is the safe way to do that??

                    S Offline
                    S Offline
                    sach
                    wrote on last edited by
                    #10

                    time_t is defined as __int64 by default!! How safe it is to declear var with __int32 instead of time_t so that i can get a 32 bit time.

                    1 Reply Last reply
                    0
                    • S sach

                      Thx That is what i am doing to get the size!! I need to use 32bit time_t so i declered #define _USE_32BIT_TIME_T But its not making any diffence!! I am still getting 8 bytes as a size of time_t var.

                      T Offline
                      T Offline
                      ThatsAlok
                      wrote on last edited by
                      #11

                      sach!! wrote:

                      But its not making any diffence!! I am still getting 8 bytes as a size of time_t var.

                      typecast it to FILETIME ! it length is 64 bit!

                      "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                      cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups