Calling C function with Pascal calling convention

Hello,
I want to integrate with an external C function that uses Pascal (=
__stdcall) calling convention. My course materials state that I should use
the extended property: Pascal='true' with my C project. This property is not
documented in the regular documentation and it does not seem to work. Does
anyone know what the way to go is?
My current work-around is to adapt the generated C code to include __stdcall
and use fcompile to get it compiled and linked.
Thanks,
Frans van der Geer
Info Support

Hi Grarup,
I took a stab at getting this to run and compile and this is what I came up with.  Let me know if this helps at all.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
class Program
static void Main(string[] args)
Console.WriteLine("\"True\" or \"False\"?");
bool boolVal = bool.Parse(Console.ReadLine());
Functions f = new Functions();
TestStruct t = new TestStruct() { Value = boolVal };
f.Flip(ref t);
Console.WriteLine(string.Format("Flipped value = {0}: ", t.Value));
Console.ReadLine();
public struct TestStruct
public bool Value;
public class Functions
public void Flip(ref TestStruct testStruct)
testStruct.Value = !testStruct.Value;
Best of luck.

Similar Messages

  • How to build a DLL that has Pascal calling conventions with application builder?

    Hi,
    I'm researching for possible solution to one of our problems.
    In one case, solution would be to build a DLL from LabView
    code. This should be simple task, but the application that
    is going to load the DLL requires that the functions in the
    library are exported using Pascal calling conventions,
    similar to the C/C++ example code below.
    DWORD APPEXPORT far APPPASCAL function(char hexr[])
    Could this be possible with LabView somehow? Or is it best just
    to write the DLL with C/C++?
    Thanks.

    Thanks Wiebe.
    I don't know whether I need pass string pointers or not. The example
    I posted was from the manual of the program that will be using the DLL
    I build with LabView. I only wanted to show with it the exported calling
    convention needed. It seems that it actually confused my question rather
    than clearing it.
    Anyway, now I know that it's possible to declare the calling convention
    when building the DLL. And it's always good to know that I might encounter
    different pointer types on the way, this may actually save me from a lot of
    debugging some day.

  • Calling conventions for C functions for the VFP

    If I write a function like this:
    float test(float a)
    return a*a;
    And then I look at the assembly code generated:
    _test:
    LFB48:
    LM1:
    @ args = 0, pretend = 0, frame = 0
    @ frame_needed = 0, usesanonymousargs = 0
    @ link register save eliminated.
    LVL0:
    LM2:
    fmsr s14, r0
    LM3:
    @ lr needed for prologue
    LM4:
    fmuls s13, s14, s14
    fmrs r0, s13
    LVL1:
    bx lr
    The question is, why are the input register to this function belong to ARM and not to VFP? Surly the input registers should be S0 and not R0. This seems bad to me because the ARM register needs to be converted to a VFP register and then reconverted back to a CPU register after the calculation.
    I thought C calling conventions were R0-R3 for ARM and S0-S7 for VFP?
    Is there a way to make the compiler follow this convention?

    C++ can call on C code as long as C++ is given instructions that the function prototypes are in fact C functions, and not C++ functions.
    You have to do this since C and C++-s scheme of handling function names at the object code level are different. By invoking the extern "C" {}, the compiler will generate object code that can link against C code.
    You have maybe seen C header files with
    #ifdef __cplusplus
    extern "C" {
    #endif
    //... prototypes here
    #ifdef __cplusplus
    #endif
    Last edited by Themaister (2010-05-15 20:19:35)

  • How to call a function with pl/sql

    How does one call a function with pl/sql that uses a function?

    Hi,
    How does one call a function with pl/sql that uses a
    function?I'm not sure what you mean.
    In PL/SQL function can be used just about anywhere where an expression (with the same data type that the function returns). Arpit gave a very common example.
    Here's another example, where all the functions take a single NUMBER argument and return a NUMBER, so they can all be used in places where NUMBERs are used:
    IF  fun_a (fun_b (0)) < fun_c (1)
    THEN
        UPDATE  table_x
        SET     column_y = fun_d (2)
        WHERE   column_z = fun_e (ROUND ((fun_f (3), fun_g (4)));You call a function simply by using its name, followed by its argument list, if any.
    If the function is in a package, you must call it with the package name, like "pk_foo.bar (1, 2, 3)", unless the call comes from within the same package.
    If the function is owned by someone else, you must give the owner name, like "scott.bar (SYSDATE)" or "scott.pk_foo.bar (1, 2, 3)". You can create synonyms to avoid having to name the owner.

  • Call outside function with same name in a package

    I created a function as follows:
    create or replace function f1 return number
    is
    begin
    return 1;
    end;
    This f1 is to be called in a package created below.
    Then I create a package with a function in it, as follows:
    create or replace package pack1 as
    function f1 return number;
    end;
    Now I define the package body as follows:
    create or replace package body pack1 as
    function f1 return number as
    -- I am trying to call the first function f1 defined above here
    How do I resolve the name issues here?
    In other words, I want to call a function with the same signature outside a package.
    Thanks for your kind help.

    Hi,
    Welcome to the forum!
    Do you have a good reason for using the same name?
    Refer to the stand-alone function with the owner name, even though it's your current schema.
    That is, even if the package and the stand-alone function are owned by scott, in the package, say
    x := scott.f1;

  • Is there a way to call a function with in the initializer of a ArrayCollection?

        Is there a way to call a function with in the initializer of a ArrayCollection?
    It won't let me do this:
    var ac:ArrayCollection = new ArrayCollection([
                        {childName:'addTrade',index:addTradeIndex },
                        {childName:'tradeList',dealsCanvas.getChildIndex(tradeList) }

    The correct syntax is
    var ac:ArrayCollection = new ArrayCollection([
                        {childName:'addTrade',index:addTradeIndex },
                        {childName:'tradeList',index:dealsCanvas.getChildIndex(tradeList) }

  • Calling a object of class from other class's function with in a package

    Hello Sir,
    I have a package.package have two classes.I want to use object of one class in function of another class of this same package.
    Like that:
    one.java
    package co;
    public class one
    private String aa="Vijay";  //something like
    }main.java:
    package co;
    import java.util.Stack;
    public class main extends Stack
    public void show(one obj)
    push(obj);
    public static void main(String args[])
    main oo=new main();
    }when I compile main class, Its not compile.
    Its give error.can not resolve symbol:
    symbol: class one
    location: class co.main
    public void show(one obj)
                              ^Please help How that compile "Calling a object of class from other class's function with in a package" beacuse I want to use this funda in an application

    kumar.vijaydahiya wrote:
    .It is set in environment variable.path=C:\bea\jdk141_02\bin;.,C:\oraclexe\app\oracle\product\10.2.0\server\bin;. command is:
    c:\Core\co\javac one.javaIts compiled already.
    c:\Core\co\javac main.javaBut it give error.
    Both java classes in co package.Okay, open a command prompt and execute these two commands:
    // to compile both classes:
    javac -cp c:\Core c:\Core\co\*.java
    // to run your main-class:
    java -cp c:\Core co.main

  • How to call a function with event

    How do I call a function with a event inside it?
    function showTopTen(e:Event):void
        highscoreData = new XML(e.target.data);
        trace("Hiscores: " + highscoreData.item[0].name.text() + " - " + highscoreData.item[0].score.text())
    //showTopTen();  ..??

    Could you indicate why you would want to?
    The eventhandler you show here uses the properties of the event object passed as an argument.
    The way I read it it is data retrieved from a server so your app won't know anything about is untill it is loaded from the server which should be done with an URLLoader object which in it's turn calls your eventHandler when the Event.COMPLETE is triggered.
    something like:
    var urlLoader = new URLLoader();
    urlLoader.addEventListener( Event.COMPLETE, showTopTen )
    urlLoader.load( new URLRequest( "http:// etc." ) );
    to me would seem the proper method to have the function execute.

  • Call function with DML

    I have a function that performs DML. I am calling the function from toplink with the following. I get an error
    ORA-14551: cannot perform a DML operation inside a query when I try to execute this function. Is there another way to call functions without using select From dual?
    String queryFunc = "SELECT " +
    "CCU.adjPaymentTrans(#caseID, #obligorPIN, #ccuPIN, #transCd, #payorTp) " +
    "FROM dual";
    SQLCall sqlCallFunc = new SQLCall(queryFunc);
    ValueReadQuery valueReadFunc = new ValueReadQuery(sqlCallFunc);
    valueReadFunc.addArgument("caseID");
    valueReadFunc.addArgument("obligorPIN");
    valueReadFunc.addArgument("ccuPIN");
    valueReadFunc.addArgument("transCd");
    valueReadFunc.addArgument("payorTp");
    valueReadFunc.bindAllParameters();
    Vector theArgumentValuesFunc = new Vector(6);
    theArgumentValuesFunc.add(caseID);
    theArgumentValuesFunc.add(obligorPIN);
    theArgumentValuesFunc.add(ccuPIN);
    theArgumentValuesFunc.add(transCd);
    theArgumentValuesFunc.add(payorTp);
    Number amountReversed = (Number)uow.executeQuery(valueReadFunc, theArgumentValuesFunc);

    Normally DML is only done from stored procedures, not stored functions, you may want to consider changing the function to a procedure.
    To call a function that does DML, you must call the function through a PLSQL call. If you did not require the return value, the code would be:
    >>
    String queryFunc = "begin " +
    "CCU.adjPaymentTrans(#caseID, #obligorPIN, #ccuPIN, #transCd, #payorTp);" +
    "end;";
    SQLCall sqlCallFunc = new SQLCall(queryFunc);
    DataModifyQuery modifyFunc = new DataModifyQuery(sqlCallFunc);
    >>
    If you require the return value, then the SQL would be:
    >>
    String queryFunc = "begin ? = " +
    "CCU.adjPaymentTrans(?, ?, ?, ?, ?);" +
    "end;";
    >>
    However this would have to be executed through a CallableStatement in JDBC. TopLink currently only supports executing stored procedures as callable statements, so you would need to execute this directly through JDBC. You could also convert the function to a procedure, or wrap the function with a procedure. I believe TopLink 10.1.3 will have support for a StoredFunctionCall that can call DML stored functions.
    To get a JDBC connection from a TopLink session uses,
    UnitOfWork uow = session.acquireUnitOfWork();
    uow.beginEarlyTransaction()
    uow.getAccessor().getConnection();
    uow.commit();

  • My iphone 4 fell down from 3 feet height and display is not working now, phone is functioning with calls and messages etc.. except no display :( please advise me a corrective action...

    my iphone 4 fell down from 3 feet height and display is not working now, phone is functioning with calls and messages etc.. except no display please advise me a corrective action...

    Take it to an Apple Store and see about getting an out of warranty replacement. I believe it will run you about $150.

  • How to call java function with parameter from javascript in adf mobile?

    how to call java function with parameter from javascript in adf mobile?

    The ADF Mobile Container Utilities API may be used from JavaScript or Java.
    Application Container APIs - 11g Release 2 (11.1.2.4.0)

  • WEBUTIL_C_API: Writing wrapper DLL's to address calling convention issues

    I am interested in calling the Windows API using WEBUTIL_C_API. In particularly, I am interested in calling FindWindow to obtain window handles. I registered the function as required, but have yet to get a meaningful result. Upon researching Metalink a bit, I encountered a post stating that FindWindow uses Pascal calling conventions, while WEBUTIL_C_API expects C calling conventions. The suggested solution is to wrap the API call in my own DLL, which adapts between the two calling conventions.
    I'm fairly adept at writing standard C code, albeit out of practice, and with a bit of Googling, I have even managed to compile a DLL using GNU gcc. Alas, I evidently don't understand all the compiler directives required to write the wrapper DLL that I have described. Has anyone else managed a similar task, who might share an example or direct me to some helpful documentation?
    Thanks,
    Eric Adamson
    Lansing, Michigan

    Mr. Ronald,
    Thank you for your assistance. After going through the webutil log file and the WebUtil Familiarization Manual a few more times, and lastly, metalink, it was stated in a metalink post that the "Cause for the Error WUC-20 can be that the webutil.cfg file has an invalid virtual directory: install.syslib.location".
    According the WebUtil Familiarization Manual (p.11 of 49), install.syslib.location=/webutil. I did just that, and the log file indicated that
    xxx.xxx.xxx.xxx:xxxxxxx: 2004-Jan-22 11:32:53.746 WUI[setProperty()] Setting property WUC_GET_LOCAL_PROPERTY to syslib.ffisamp.dll
    xxx.xxx.xxx.xxx:xxxxxxx: 2004-Jan-22 11:32:53.761 WUI[getProperty()] Getting property WUC_GET_LOCAL_PROPERTY
    xxx.xxx.xxx.xxx:xxxxxxx: 2004-Jan-22 11:32:53.761 WUI[loadSettings()] No local properties file to load
    xxx.xxx.xxx.xxx:xxxxxxx: 2004-Jan-22 11:32:53.761 WUI[getProperty()] Value of WUC_GET_LOCAL_PROPERTY=null
    xxx.xxx.xxx.xxx:xxxxxxx: 2004-Jan-22 11:32:53.777 WUI[setProperty()] Setting property WUC_URL_DOWNLOAD to 1|40960|Y|/webutil/ffisamp.dll|ffisamp.dll|WebUtil Install|Downloading required libraries; Please wait...|ffisamp.dll
    xxx.xxx.xxx.xxx:xxxxxxx: 2004-Jan-22 11:32:53.777 WUI[getProperty()] Getting property WUC_URL_DOWNLOAD
    xxx.xxx.xxx.xxx:xxxxxxx: 2004-Jan-22 11:32:53.777 WUI[downloadFromURL()] Source is http://<machine_name:port>/forms90/f90servlet/webutil/ffisamp.dll
    So I tried the absolute URL, http://<machine_name:port>/forms90/webutil, Voila! It worked. The point is somehow, the download url should not include .../f90servlet/...; just plain /forms90/webutil.
    Thank you for your time and assistance.
    Regards,
    thomas

  • Bad DLL Calling Convention

    Hi,
    I've created a dll with LV8.6 and I'm trying to call it from VB6.0.  I get the message 'Bad Dll Calling Convention.  Run Time Error '49'.
    Questions:
    1.  Any idea what might cause this error?
    2.  What is the meanig of the second function appear inh the h file ( long __cdecl LVDLLStatus(char *errStr, int errStrLen, void *module)
    Thanks very much for your help
    Rafi
    The dll definition as appear in the h file:
         void __stdcall EDASAnalysis(double f_sampleMHz, char FilePathFromOut[],
             double *RMSValue, double *AmplitudePP);
         long __cdecl LVDLLStatus(char *errStr, int errStrLen, void *module);
    The Decleration in Visual Basic 6.0:
         Declare Sub EDASAnalysis Lib "D:\NI Projects\eDAS400\DLL\ LV-DLL_V2\DLL\eDAS400_Analysis.dll" _
                (ByVal f_sampleMHz As Long, ByVal FilePath As String, RMSValue As Long, AmplitudePP As Long)
    Using the Function in VB6.0:
        Call EDASAnalysis(10, "D:\NI Projects\eDAS400\Data Files\Samples\10MHz.txt", rms, pp)

    Rafi2003 wrote:
    Hi,
    I've created a dll with LV8.6 and I'm trying to call it from VB6.0.  I get the message 'Bad Dll Calling Convention.  Run Time Error '49'.
    Questions:
    1.  Any idea what might cause this error?
    2.  What is the meanig of the second function appear inh the h file ( long __cdecl LVDLLStatus(char *errStr, int errStrLen, void *module)
    Thanks very much for your help
    Rafi
    The dll definition as appear in the h file:
         void __stdcall EDASAnalysis(double f_sampleMHz, char FilePathFromOut[],
             double *RMSValue, double *AmplitudePP);
         long __cdecl LVDLLStatus(char *errStr, int errStrLen, void *module);
    The Decleration in Visual Basic 6.0:
         Declare Sub EDASAnalysis Lib "D:\NI Projects\eDAS400\DLL\ LV-DLL_V2\DLL\eDAS400_Analysis.dll" _
                (ByVal f_sampleMHz As Long, ByVal FilePath As String, RMSValue As Long, AmplitudePP As Long)
    Using the Function in VB6.0:
        Call EDASAnalysis(10, "D:\NI Projects\eDAS400\Data Files\Samples\10MHz.txt", rms, pp)
    muks already pointed you to a discussion that shows the problem. VB can not call cdecl exported functions, so when you create your DLL you'll have to tell LabVIEW to use the stdcall calling convention to export the function for VB.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • DLL calling convention

    I wonder what calling convention I should select at the call library node for these 2 cases of DLL
    if my functions in the DLL are declared as follow;
    1. extern "C" void PASCAL EXPORT my_function()
    2. void __declspec(dllexport) my_function2()
    thanks

    The first one uses the obsolete type PASCAL. This has been mapped to __stdcall so that is what you should put in your Call Library Node.
    The second one doesn't declare an explicit calling convention so I have to make some assumptions:
    1. This is not a member fuction of a C++ class.
    2. You haven't defined an explicity calling convension in the compiler (such as /Gz or /Gr).
    In that case, it defaults to __cdecl.
    Brian Tyler
    http://detritus.blogs.com/lycangeek

  • Calling convention mismatch

    Hello,
    I am using Labwindows CVI 10.0.1. I am including a header which has several function declared like this;
     __declspec(dllexport) int __stdcall func1(int x);
     __declspec(dllexport) int __stdcall func2(int x);
     __declspec(dllexport) int __stdcall func3(int x);
    I want to store an array of structs which contain a pointer to those functions. I declare the struct and array like this;
    typedef struct {
      int __stdcall (* apiFunc)(int);
      int setpoint;
    } storedFuncs_t;
    storedFuncs_t funcs[] = { {func1, 1}, {func2, 2}, {func3, 3} };
    Then I execute the functions like this;
    for (int i=0; i <3; ++i)
      funcs[i].apiFunc(funcs[i].setpoint);  
    I get the following runtime error when executing debug build;
    NON-FATAL RUN-TIME ERROR: "tests.c", line 362, col 18, thread id 0x000022AC: CVI has detected an inconsistency of the run-time stack. This might have been caused by a calling convention mismatch in the last function call.
    I've tried chaning the placement of the calling convention as suggested in other posts, like this
    typedef struct {
      int (*__stdcall  apiFunc)(int);
      int setpoint;
    } storedFuncs_t;
    Also, I look at the array  in the variable window and see it displayed like this;
      int (__stdcall  *)(int)
    Also, default calling convention in build options is set to __stdcall.
    Any advice would be really helpful.
    Thanks,
    Morgan

    Might it be a problem with the calling convention in the build options? This help document details a little about using stdcall over cdecl.
    http://zone.ni.com/reference/en-XX/help/370051T-01/cvi/usermanual/prjbuildopt/
    Rob S
    Applications Engineer
    National Instruments

Maybe you are looking for

  • Best Practice for Conversion Workflow

    Hello, I'm converting video files from our "home grown" virtual media reserve to iTunes U. Some of the files are in RM format, some are already compressed .mov's (not H.264) and some I have the original DV files for. Anyone out there have a best prac

  • Deadline Branch not working

    Hi All, I configured  a simple BPM scenario with a Block step with 3 braches namely 1. Normal Branch(one receive step with in infinite loop step). 2. dead line branch with 1 min timeout. within this a control step to throw exception 3. Exception bran

  • MIRO invoice verification PO multiselect - how to enable totals for PO

    Hello, Having (multi) selected PO, we wish to enable Edit -> Calculate -> Totals in the "Possible Entries for Purchasing Document ..." screen (SAP ECC 6.0, MIRO, Program SAPLKKBL, GUI RM08RL82, status 0001). I guess some configuration might be needed

  • Dynamic lov, Select List in Report

    Hi all, I have searched the APEX forum for dynamic lov but somehow no topic could really solve my problem. I have a report and 2 columns in this report are displayed as a select list. I want one of the select list show some values depending on the ot

  • Cfdirectory thinks directory is a file

    I have a utility that allows the user to select a top-level directory, then displays a list of files in the directory as hyperlinks.  Any subdirectories are displayed separately and the hyperlink changes the default directory to that subdirectory whe