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. i have a erro in vc6

i have a erro in vc6

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
11 Posts 7 Posters 1 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.
  • C CHYGO

    struct nids_prm { ... void (*syslog) (); ... }; static void my_nids_syslog(int type, int errnum, struct ip_header *iph, void *data) {} main() { nids_params.syslog = my_nids_syslog; ... } error C2440: '=' : cannot convert from 'void (__cdecl *)(int,int,struct ip_header *,void *)' to 'void (__cdecl *)(void)' how to solve it?:rose::rose:

    R Offline
    R Offline
    Rajkumar R
    wrote on last edited by
    #2

    CHYGO wrote:

    error C2440: '=' : cannot convert from 'void (__cdecl *)(int,int,struct ip_header *,void *)' to 'void (__cdecl *)(void)'

    i think i cannot explain more clear than that. function parameters are not same.

    CHYGO wrote:

    how to solve it?

    it depends on your need, may be,

    struct nids_prm
    {
    ...
    void (*syslog) (int,int,struct ip_header *,void *);
    ...
    };

    matches your need. BTW, a basic C programing book can also solve.

    C 1 Reply Last reply
    0
    • C CHYGO

      struct nids_prm { ... void (*syslog) (); ... }; static void my_nids_syslog(int type, int errnum, struct ip_header *iph, void *data) {} main() { nids_params.syslog = my_nids_syslog; ... } error C2440: '=' : cannot convert from 'void (__cdecl *)(int,int,struct ip_header *,void *)' to 'void (__cdecl *)(void)' how to solve it?:rose::rose:

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #3

      Short answer: this way

      struct nids_prm
      {
      ...
      void (*syslog) (int , int , struct ip_header *, void *);
      ...
      };

      Long answer: use variable number of argument for your functions (and modify accordigly syslog declaration). :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

      In testa che avete, signor di Ceprano?

      C 1 Reply Last reply
      0
      • C CHYGO

        struct nids_prm { ... void (*syslog) (); ... }; static void my_nids_syslog(int type, int errnum, struct ip_header *iph, void *data) {} main() { nids_params.syslog = my_nids_syslog; ... } error C2440: '=' : cannot convert from 'void (__cdecl *)(int,int,struct ip_header *,void *)' to 'void (__cdecl *)(void)' how to solve it?:rose::rose:

        C Offline
        C Offline
        Cadimi
        wrote on last edited by
        #4

        In nids_prm struct, replace void (*syslog) (); with this: void ( *syslog ) ( int , int , struct ip_header * , void * ); When you declare a function pointer, you have to define exactly the parameters of that function ^^. Enjoy yourself ^^

        C 1 Reply Last reply
        0
        • C CHYGO

          struct nids_prm { ... void (*syslog) (); ... }; static void my_nids_syslog(int type, int errnum, struct ip_header *iph, void *data) {} main() { nids_params.syslog = my_nids_syslog; ... } error C2440: '=' : cannot convert from 'void (__cdecl *)(int,int,struct ip_header *,void *)' to 'void (__cdecl *)(void)' how to solve it?:rose::rose:

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

          CHYGO wrote:

          cannot convert from 'void (__cdecl *)(int,int,struct ip_header *,void *)' to 'void (__cdecl *)(void)'

          that's pretty clear, no ? you're passing parameters to a function which requires none !

          [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

          C 1 Reply Last reply
          0
          • T toxcct

            CHYGO wrote:

            cannot convert from 'void (__cdecl *)(int,int,struct ip_header *,void *)' to 'void (__cdecl *)(void)'

            that's pretty clear, no ? you're passing parameters to a function which requires none !

            [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

            C Offline
            C Offline
            CHYGO
            wrote on last edited by
            #6

            i don't know what's the problem is -_-! when i drag the .c file into the VC6, the build the default project,then compile ,nothing happen but when i build a WIN32 or MFC application , the error occur...

            E 1 Reply Last reply
            0
            • C Cadimi

              In nids_prm struct, replace void (*syslog) (); with this: void ( *syslog ) ( int , int , struct ip_header * , void * ); When you declare a function pointer, you have to define exactly the parameters of that function ^^. Enjoy yourself ^^

              C Offline
              C Offline
              CHYGO
              wrote on last edited by
              #7

              i've tried ,and the error is the same

              1 Reply Last reply
              0
              • C CHYGO

                struct nids_prm { ... void (*syslog) (); ... }; static void my_nids_syslog(int type, int errnum, struct ip_header *iph, void *data) {} main() { nids_params.syslog = my_nids_syslog; ... } error C2440: '=' : cannot convert from 'void (__cdecl *)(int,int,struct ip_header *,void *)' to 'void (__cdecl *)(void)' how to solve it?:rose::rose:

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #8

                There are two possible solutions available to you: 1)

                void (*syslog)(int, int, ip_header*, void*);

                static void my_nids_syslog()

                "Love people and use things, not love things and use people." - Unknown

                "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                1 Reply Last reply
                0
                • C CHYGO

                  i don't know what's the problem is -_-! when i drag the .c file into the VC6, the build the default project,then compile ,nothing happen but when i build a WIN32 or MFC application , the error occur...

                  E Offline
                  E Offline
                  Elias Fotinis
                  wrote on last edited by
                  #9

                  When you build the single .c file, VC6 treats the code as valid C. The WIN32/MFC app is probably treating the code as C++, which in this case is invalid.

                  1 Reply Last reply
                  0
                  • R Rajkumar R

                    CHYGO wrote:

                    error C2440: '=' : cannot convert from 'void (__cdecl *)(int,int,struct ip_header *,void *)' to 'void (__cdecl *)(void)'

                    i think i cannot explain more clear than that. function parameters are not same.

                    CHYGO wrote:

                    how to solve it?

                    it depends on your need, may be,

                    struct nids_prm
                    {
                    ...
                    void (*syslog) (int,int,struct ip_header *,void *);
                    ...
                    };

                    matches your need. BTW, a basic C programing book can also solve.

                    C Offline
                    C Offline
                    CHYGO
                    wrote on last edited by
                    #10

                    thx, i need another mothes:) i'll try it

                    1 Reply Last reply
                    0
                    • CPalliniC CPallini

                      Short answer: this way

                      struct nids_prm
                      {
                      ...
                      void (*syslog) (int , int , struct ip_header *, void *);
                      ...
                      };

                      Long answer: use variable number of argument for your functions (and modify accordigly syslog declaration). :)

                      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

                      C Offline
                      C Offline
                      CHYGO
                      wrote on last edited by
                      #11

                      thank u:)

                      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