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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Converting calloc to new.

Converting calloc to new.

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
5 Posts 3 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.
  • B Offline
    B Offline
    BubbaGeeNH
    wrote on last edited by
    #1

    I'm trying to convert some old code that is using 'calloc' to use 'new' but I'm having a little trouble with this: void (**temp_stack)(void); temp_stack=(void (**)())calloc(count+1,sizeof(void *)); I tried using this: void (**temp_stack)(void); temp_stack=new (void*[count+1]); but get the following error: error C2440: '=' : cannot convert from 'void ** ' to 'void (__cdecl ** )(void)' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast Can anyone help me figure it out? Thanks, George

    George

    C N 2 Replies Last reply
    0
    • B BubbaGeeNH

      I'm trying to convert some old code that is using 'calloc' to use 'new' but I'm having a little trouble with this: void (**temp_stack)(void); temp_stack=(void (**)())calloc(count+1,sizeof(void *)); I tried using this: void (**temp_stack)(void); temp_stack=new (void*[count+1]); but get the following error: error C2440: '=' : cannot convert from 'void ** ' to 'void (__cdecl ** )(void)' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast Can anyone help me figure it out? Thanks, George

      George

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      void (**temp_stack)(void);
      temp_stack=(void (**)())calloc(count+1,sizeof(void *));

      :confused: that doesn't even compile in VC6.

      image processing toolkits | batch image processing

      N 1 Reply Last reply
      0
      • C Chris Losinger

        void (**temp_stack)(void);
        temp_stack=(void (**)())calloc(count+1,sizeof(void *));

        :confused: that doesn't even compile in VC6.

        image processing toolkits | batch image processing

        N Offline
        N Offline
        Nemanja Trifunovic
        wrote on last edited by
        #3

        Chris Losinger wrote:

        that doesn't even compile in VC6.

        It does in VC2010. What is the error message you got?

        utf8-cpp

        C 1 Reply Last reply
        0
        • N Nemanja Trifunovic

          Chris Losinger wrote:

          that doesn't even compile in VC6.

          It does in VC2010. What is the error message you got?

          utf8-cpp

          C Offline
          C Offline
          Chris Losinger
          wrote on last edited by
          #4

          error C2563: mismatch in formal parameter list

          image processing toolkits | batch image processing

          1 Reply Last reply
          0
          • B BubbaGeeNH

            I'm trying to convert some old code that is using 'calloc' to use 'new' but I'm having a little trouble with this: void (**temp_stack)(void); temp_stack=(void (**)())calloc(count+1,sizeof(void *)); I tried using this: void (**temp_stack)(void); temp_stack=new (void*[count+1]); but get the following error: error C2440: '=' : cannot convert from 'void ** ' to 'void (__cdecl ** )(void)' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast Can anyone help me figure it out? Thanks, George

            George

            N Offline
            N Offline
            Nemanja Trifunovic
            wrote on last edited by
            #5

            This should work:

            typedef void(* void_pp_fn)(void);
            void_pp_fn* temp_stack=new void_pp_fn[count+1];

            utf8-cpp

            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