33755

Function pointer in Visual Studio 2012

Question:

Please explain me where I am wrong. I want to switch between several encoding utilities using pointer to function. I declare it like

int (*enc_routine)();

Later I switch coding utilities like

enc_routine = g723_24_encoder;

where utility by itself is something like

extern int g723_24_encoder( int sample, int in_coding, struct g72x_state *state_ptr);

Everything was cute and fine on Linux, but now I am on Visual Studio 2012 and it says:

<blockquote>

a value of type "int (*)(int sample, int in_coding, g72x_state *state_ptr)" cannot be assigned to an entity of type "int (*)()"

</blockquote>

Thank you for help (if any)!

Answer1:

You need to declare the parameters for your function pointer. You can't declare it to take no parameters and set it equal to a function that requires 3 parameters. I'm shocked it worked on linux.

Recommend

  • Fastest way to read a text file of strings line by line [duplicate]
  • Shell variable expansion - indirection while calling a utility with env
  • Calculate the depth of subclass in the OWL ontology
  • How to prevent TreeItem selection?
  • cordova.js for android phonegap application
  • How do I pass worksheet and ranges as variables?
  • Custom Keyboard or to create own keyboard
  • C++ Boost ptr_map serialization error
  • mysql select inside limit
  • set operation within a list column
  • How to remote debug with Delve debugger in Visual Studio Code
  • ruby/rails: extending or including other modules
  • Android Oreo JobIntentService Keep running in background for Android 7 &below and crashing often
  • How to clip image to ellipse in XAML
  • How to escape colon (:) character while executing native SQL queries against an Informix database us
  • Get sibling of Vaadin Tree Item?
  • Firebase firestore cloud functions showing trigger type 'unknown'
  • DateTime differences between rows in a database
  • how to verify a P12 certificate using openssl?
  • how to pass class attribute and value to markdown syntax
  • Run EF6 Query in separate Thread on WinForm Button Click Event
  • integration of function in modelica
  • Leaflet z-index
  • Cursor in wrong place in contenteditable
  • Basic defensive programming [duplicate]
  • Get current user from inside the model in Sails
  • C function strchr - How to calculate the position of the character?
  • Geom_jitter colour based on values
  • back button function for phonegap windows phone 7
  • TFS - how do I sum child task hours to parent
  • Select value from xtype selection type checkbox CQ5
  • Cuda Clang and OS X Mavericks
  • How to make R's read_csv2() recognise the text characters properly
  • android.support.v7.widget.Toolbar VectorDrawableCompat IllegalStateException when using support lib
  • JqueryMobile Popup menu is not working
  • Reading a file into a multidimensional array
  • Android application: how to use the camera and grab the image bytes?
  • How to clear text inside text field when radio button is select
  • Scrapy recursive link crawler
  • Run Powershell script from inside other Powershell script with dynamic redirection to file