Pointer to void != pointer to function

Hello C experts,
this is a simple question about SunStudio's understanding of function pointers (it might have been asked before):
Why is the following C code giving me a warning on all Sun compilers:
# cat funcptr.c
int main() {
    void (*func)() = (void*)0;
    return 0;
# cc -c funcptr.c
"funcptr.c", line 2: warning: assignment type mismatch:
     pointer to function() returning void "=" pointer to voidIs the warning emitted by Sun compiler a bug (over-cautions). Other compiler's don't warn here.
Of course, I could use 0 or NULL as rvalue but I'm just wondering...
Jochen

Thanks everybody for your opinions.
@Stephen:
I wasn't aware that data pointers and function pointers may differ in any aspect. In fact, I only know data models that talk about 'pointer' width in general, like LP64 (64-bit wide long- and pointertypes), ILP32 (32-bit wide int-, long- and pointer-types), .. I'm especially surprised to hear that casting between data/function pointers will result in undefined behavior.
Anyway, to properly 'fix' the code above, I must cast the zero to a function pointer (with matching signature) instead of a void pointer. This compiles w/o a warning:
    void (*func)() = (void (*)())0;Thanks for clarification.
Jochen

Similar Messages

  • Calling C function that has Void* pointer

    Hi
    I am trying to use some c functions in java using the JNI. This C function has 3 inputs, 2 integers and a void* pointer. I can import the 2 integers from java but dont know how to deal with the void* pointer.
    I would be greatful if someone could help me with this problem.
    Thanks
    Derek

    Hi,
    i guess the void * points to some C thingy. If you got
    the void * from C (via JNI), treat it as a long and cast it back in JNI
    as andyba suggested. If it is more than this (e.g. a C++ object)
    there is no general solution, but there are numerous special ones.
    If you tell a little more concrete what your void * points to,
    there might be more concrete suggestions.
    To get an idea, study e.g. swig's java module. But be warned,
    this is no simple topic.
    http://swig.sourceforge.net
    Have fun,
    Klaus

  • Import CVI Instrument driver with void pointer

    Hi,
    I would like to use a CVI instrument driver that contains void pointers as parameters in LabVIEW. There are additional parameters which declare the kind of data where the void pointer points to.
    If I try to import this driver to LabVIEW I get warnings that the void pointer paarameters are converted to I32 since LabVIEW do not have the void pointer.
    Does anybody know if it is possible to import a CVI function with void pointers that will work properly in LabVIEW? How do I have to handle this converted void pointer?
    Thnaks,
    erik.

    Erik,
    you may have a look at this discussion forum thread.
    Best regards,
    Jochen Klier
    National Instruments Germany

  • How do I pass a void *pointer to a dll in LabView

    I did read previous posts on the matter and tried just about everything, inlcuding defining the pointer as a U32 int.
    What I am trying to do is program FLASH using WindRiver VisionPROBE EST...
    I do have some sucesses... )
    I can open a connection to the EST, initialize it, start & stop the target. No problem here..
    Here are some additional details:
    I can't read memory, write to the target register or program the FLASH, yet. Any advice on how to get further with this? Typically, when doing this using WR's visionClick sw, we need to use a register file which sets up the target. I have not seen any reference to this in their API.
    I can convert to CVI if necessary. I am using the dll's from WindRi
    ver. I'd prefer keeping everything in LV, but LW-CVI is fine.
    My problem is that I am not sure if I am passing void pointers back & forth correctly. For instance, I need to call a function which returns a status, as follows:
    status = EST_WriteTargetRegister (long handle, Unsign int register, void * value)
    How do I pass the "void * value" to the input of a Call Library FUnction Node. I did try "Adapt to type" which does give a "void * value", and I tried both "Handles by Value" & "Pointers to Handles".
    When I change the input value to anything other than "Adpapt To Type", I get a violation error. >(
    Has anyone successfully automated WindRiver's EST?
    - Thanks -
    JLV"

    Hi,
    Have you tried passing a I32, but selecting "Pointer To Value"?
    Is there any description about the "void *pointer"? Could it be a callback
    function?
    Regards,
    Wiebe.
    "JoeLabView" wrote in message
    news:[email protected]..
    > I did read previous posts on the matter and tried just about
    > everything, inlcuding defining the pointer as a U32 int.
    >
    > What I am trying to do is program FLASH using WindRiver VisionPROBE
    > EST...
    >
    > I do have some sucesses... )
    > I can open a connection to the EST, initialize it, start & stop the
    > target. No problem here..
    >
    > Here are some additional details:
    >
    >
    >
    >
    > I can't read memory, write to the target register or program the
    > FLASH, yet. Any advice on how to get f
    urther with this? Typically,
    > when doing this using WR's visionClick sw, we need to use a register
    > file which sets up the target. I have not seen any reference to this
    > in their API.
    >
    > I can convert to CVI if necessary. I am using the dll's from
    > WindRiver. I'd prefer keeping everything in LV, but LW-CVI is fine.
    >
    > My problem is that I am not sure if I am passing void pointers back &
    > forth correctly. For instance, I need to call a function which
    > returns a status, as follows:
    >
    >
    > status = EST_WriteTargetRegister (long handle, Unsign int register,
    > void * value)
    >
    >
    > How do I pass the "void * value" to the input of a Call Library
    > FUnction Node. I did try "Adapt to type" which does give a "void *
    > value", and I tried both "Handles by Value" & "Pointers to Handles".
    >
    > When I change the input value to anything other than "Adpapt To Type",
    > I get a violation error. >(
    >
    > Has anyone successfully automated WindRiver's EST?
    >
    > - Thanks -
    >
    > JLV"

  • Where is pointer pointing to in Call Library Function

    I am  using Call Library Function (FillString) to call a function in a DLL.  I set Parameter 1 to:
    Parameter: arg1
    Type: Array
    Data Type: signed 32-bit Integer
    Dimension : 1
    Array Format: Array Data Pointer
    so the Function Prototype below in the Call Library Function dialogbox is written as:
    void FillString(long *arg1);
    At the same time, in the block diagram , there is a "input param" (array of int32) and "output param" (array of int 32)
    I wonder, when the program is in the DLL FillString function and using arg1 pointer, does "arg1" point to the data in "input param" arry or the data in "output param" array?  I don't quite understand, since normally C programs have only one return value, while the Call Library Function returns a value for every input parameter. Is the "output param" a different variable, or the same as "input param" (i.e., the same physical memory address)?

    Hi LyLee,
    if you know how many elements you need, create an array with this number of elements by using the "initialize array" function and connect it to your dll node. The output shall contain your data. If you have a string its the same. Create an empty string with the size you need. See the attached example picture.
    Mike
    Attachments:
    Unbenannt.PNG ‏3 KB

  • JNI equivalent of a void * pointer

    Hi I am writing a java wrapper for a method which returns a void * pointer. This void * pointer is then taken as input to all the other native methods I call subsequently. How should i be casting this void * pointer in Java , should it be an Object[]. Will the pointer get mangled or something while doing this cast ?

    Cast it to a long.
    Pass it to the other methods as a long and cast it back to a void*.
    Since this is probably a allocated resource you should do the following
    1. Provide a cleanup method. Call it Destroy or Close. It calls the appropriate JNI method that cleans it by calling another C/C++ method.
    2. Create a finalizer which calls the cleanup method if the value has not yet been cleaned.

  • InputStream vs void pointer

    Hi All,
    In my C program I have one void pointer. I want to send this void pointer to my Java program as InputStream. Is it possible?
    Thanks,
    javadevlson

    In my C program I have one void pointer. I want to send this void pointer to my
    Java program as InputStream. Is it possible?Sure it is. You need a bit of JNI stuff to pass that void* back to Java as a byte[];
    given that array just use a ByteArrayInputStream.
    kind regards,
    Jos

  • What is the utility of watch point and break point in ABAP DEBUGGING !

    What is the utility of watch point and break point in ABAP DEBUGGING !
    PLEASE TELL ME IN DETAILS AND IF POSSIBLE WITH SCREEN SHOTS !

    Hi,
    Breakpoints, Watchpoints, and Checkpoints
    Summary
    The standard Breakpoints tool is always located on the Breakpoints desktop. With this tool, you can manage breakpoints, watchpoints and checkpoints. In addition, you can monitor the current status of the different breakpoint types.
    Detailed Description
    Breakpoints
    In the Breakpoints area, you will see a list of all the breakpoints set so far. If one of the breakpoints has just been reached, this is marked with a yellow arrow. The visibility (Debugger, session, user) and type (line, ABAP command, …) is displayed for each breakpoint.
    If you double click the Navigation() column, the system will display the breakpoint in the respective source code.
    The visibility of a breakpoint can be changed through the dropdown list. To change the visibility of several breakpoints, mark them and select the pushbutton Save as Session Breakpoint or Save as User Breakpoint.
    You can change the visibility of all Debugger breakpoints using the menu path Breakpoints-> Save Debugger BPs as -> ....
    In addition, you have functions for creating, changing, activating and deactivating breakpoints at your disposal.
    Watchpoints
    In the Watchpoints area, you will see a list of all the watchpoints set so far. The watchpoint last set is highlighted with a yellow arrow.
    For each watchpoint you will see not only the current value but the value before the last changed. (Technically speaking, each time you create the watchpoint and each time the watchpoint variable is changed, a clone of this variable is created.)
    In this way, you can always determine what changes have been made to the monitored variable. For complicated data structures, such as internal tables or structures, select the pushbutton „Compare Variables“( ) and choose the Diff tool to compare the old and new variable values.
    In addition, you have functions for creating, changing, activating and deactivating watchpoints at your disposal.
    Checkpoints
    In addition, you can edit conditional and unconditional checkpoints using the Breakpoints tool. This function is provided in the new Debugger only. Conditional checkpoints are set first in the source code using the ASSERTstatement; unconditional checkpoints are set using the BREAK-POINT statement. These have the effect that programs will be continued only if a preset condition is fulfilled. In the following window, these checkpoints can be searched for, activated, or deactivated.
    Pls refer to :
    http://help.sap.com/saphelp_nw70/helpdata/en/e2/5f5a42ed221253e10000000a155106/frameset.htm
    Regards,
    Renjith Michael.

  • What is utility of watch points and break point  in ABAp debugging !

    What is utility of watch points and break point  in ABAp debugging !

    Hi,
    Breakpoints, Watchpoints, and Checkpoints
    Summary
    The standard Breakpoints tool is always located on the Breakpoints desktop. With this tool, you can manage breakpoints, watchpoints and checkpoints. In addition, you can monitor the current status of the different breakpoint types.
    Detailed Description
    Breakpoints
    In the Breakpoints area, you will see a list of all the breakpoints set so far. If one of the breakpoints has just been reached, this is marked with a yellow arrow. The visibility (Debugger, session, user) and type (line, ABAP command, …) is displayed for each breakpoint.
    If you double click the Navigation() column, the system will display the breakpoint in the respective source code.
    The visibility of a breakpoint can be changed through the dropdown list. To change the visibility of several breakpoints, mark them and select the pushbutton Save as Session Breakpoint or Save as User Breakpoint.
    You can change the visibility of all Debugger breakpoints using the menu path Breakpoints-> Save Debugger BPs as -> ....
    In addition, you have functions for creating, changing, activating and deactivating breakpoints at your disposal.
    Watchpoints
    In the Watchpoints area, you will see a list of all the watchpoints set so far. The watchpoint last set is highlighted with a yellow arrow.
    For each watchpoint you will see not only the current value but the value before the last changed. (Technically speaking, each time you create the watchpoint and each time the watchpoint variable is changed, a clone of this variable is created.)
    In this way, you can always determine what changes have been made to the monitored variable. For complicated data structures, such as internal tables or structures, select the pushbutton „Compare Variables“( ) and choose the Diff tool to compare the old and new variable values.
    In addition, you have functions for creating, changing, activating and deactivating watchpoints at your disposal.
    Checkpoints
    In addition, you can edit conditional and unconditional checkpoints using the Breakpoints tool. This function is provided in the new Debugger only. Conditional checkpoints are set first in the source code using the ASSERTstatement; unconditional checkpoints are set using the BREAK-POINT statement. These have the effect that programs will be continued only if a preset condition is fulfilled. In the following window, these checkpoints can be searched for, activated, or deactivated.
    Regards,
    Renjith Michael.

  • Generating intermediate points between two points

    hi,
    i want to generate the intermediate points between two specified points,is there any functionality in java that generates the intermediate points similiar to the LINEDDA in VC++/SDK.or else please to suggest a better idea of how to get this done..
    thanx

    I'm not aware of any Java method. Here's an algorithm that I think will work for you:
    Point start = new Point(...);
    Point end = new Point(...);
    int xDelta = (int)(start.getX() - end.getX());
    int yDelta = (int)(start.getY() - end.getY());
    int delta = Math.max(Math.abs(xDelta), Math.abs(yDelta));
    double xIncrement = xDelta / delta;
    double yIncrement = yDelta / delta;
    double x = start.getX();
    double y = start.getY();
    for (int i = 0; i < delta; i++)
         drawImage( x, y, ....);
         x += xIncrement;
         y += yIncrement;
    }

  • Convert non-LRS point to LRS-point

    Can you please show me how to convert a non-LRS point to a LRS point?
    The sdo_lrs.convert_to_lrs_geom function does not work with points. It returns an error:
    ORA-06531: Reference to uninitialized collection
    ORA-06512: at "MDSYS.SDO_LRS", line 1767
    Thanks
    Dave

    I got around this by creating a sql script of insert statements to insert LRS points into another table:
    spool c:\temp\convert_to_lrs_pt.sql
    set serveroutput on
    declare
    x number;
    y number;
    z number;
    CURSOR POINTS_CURSOR IS
    SELECT GEOM,FID FROM INV_TRFC_STN where fid < 3000;
    myCURSOR POINTS_CURSOR%ROWTYPE;
    begin
    DBMS_OUTPUT.ENABLE(1000000);
    for myCURSOR in POINTS_CURSOR
    LOOP
    x := myCURSOR.geom.sdo_point.x;
    y := myCURSOR.geom.sdo_point.y;
    dbms_output.put_line ('insert into test2 values ');
    dbms_output.put_line ('(mdsys.sdo_geometry(3001,41141,NULL,mdsys.sdo_elem_info_array(1,1,1),');
    dbms_output.put_line ('mdsys.sdo_ordinate_array(' &#0124; &#0124; x &#0124; &#0124; ',' &#0124; &#0124; y &#0124; &#0124; ', NULL)),' &#0124; &#0124; myCURSOR.FID &#0124; &#0124; ');');
    end loop;
    end;
    spool off
    But if there is another way I would really like to know.
    Thanks
    Dave

  • How can I convert page points into document points??

    Hello,
    How can I convert page points into document points? any API?
    I have found 2 APIs
    AIDocumentViewSuite::ArtworkPointToViewPoint( ) and
    AIDocumentViewSuite::ViewPointToArtworkPoint( )
    but I dont know what is view point and art work point.
    I think artwork point = page points and view points = document points. am I correct ???

    What do you mean by 'document points'? Do you mean document units? Like centimeters or inches? If that, there's no API to do (well, kind of in AIUser.h, but that gives you back a string with a unit suffix). Frankly, its pretty easy to just figure out the conversion values for each type of ruler unit -- there are only five or so you need -- and then write a dinky function that takes a value in one or the other, looks up the current document unit and uses that to convert the value (one function for each way). You just need to figure out everything in terms of points (since pixels == points) -- in that regard, it probably helps to know that 72 pt == 1 inch. From that you can figure out pointer-per-inch|centimeter|millimeter|pica.

  • Management point and Distribution point behind netscaler for virtual ip/dns name

    Is it supported to place a server behind a netscaler for using a virtual IP/DNS name?
    We are looking into placing our distribution points and management points behind the netscaler to provide firewall functionality.
    We would point our clients to a different DNS name for each individual MP and DP to provide routing through the netscaler.
    As far as I know this is only possible using IBCM.
    Please let me know if this is possible without IBCM internally.

    Using a different DNS name is problematic as there is no way to specify an alternate fqdn for a site system on the intranet. Clients use the actual fqdn of the system hosting the role; this is given out by the MP directly to the client based upon the site
    system's actual name.
    You could manipulate name resolution in a variety ways so ultimately the actual IP used wouldn't matter, but that's useless unless the client is using the proper name.
    If you you could use the same name and IP, then it should work no problem as long as the traffic is properly delivered to the site system. Ultimately, nearly all client agent to site system traffic is nothing more than WebDAV via IIS on the site system so
    just basic web traffic.
    Jason | http://blog.configmgrftw.com | @jasonsandys

  • How can I find a turning point or inflection point on the curve?

    I have encountered a problem, is seeking a turning point or inflection point on the curve.
    The curve is monotonically increasing (slope is essentially the same); the slope tends to 0 after the turning point. Because of the curve is not actually a straight line, so the derivative of point by point seems comparison difficult.
    First, I intercepted two new curves from the curve.  One with monotonically increasing slope and another with remained constant slope. And I transform the two new curves to two absolutely straight with “regression” filter. Then find the intersection point of two absolutely straight. Through the X coordinate of the intersection point to find the corresponding Y value on the curve.Turning point is (x, y).
    However, this method can only be used for a fixed curve. Because the range of the intercept values ​​need to give the range, if the new changes in the overall length of the curve, the value of this range may no longer apply.
    My question is:  Is there a better way, or Diadem functions associated itself can solve this problem?
    Any of your ideas and suggestions is important to me, thanks very much.
    Best Regards
    Jie
    Solved!
    Go to Solution.
    Attachments:
    inflection point.JPG ‏131 KB

    Hi J. Huang,
    I would recommend the following generic approach, based on the pictures you submitted:
    1)  Create a smoothed channel from the raw data curve to remove random variations
    2)  Calculate a derivative/slope channel from the smoothed channel
    3)  Use the ChnFind() function to find the points where...
            the slope is close to zero
            the slope is positive
            the raw data is positive
            the raw data is close to the maximum channel value
    Brad Turpin
    DIAdem Product Support Engineer
    National Instruments

  • Converting Oriented Points to Simple Points (SDO_POINT)

    Does anyone know of a utility or script to convert oriented 3D points to simple points?

    Hi,
    The below script is to get simple point from 2D oriented point. You can easily modify this for 3D point.
    CREATE OR REPLACE FUNCTION getPoint(geom SDO_GEOMETRY) RETURN SDO_GEOMETRY IS
    BEGIN
    if geom.SDO_ORDINATES is not null and geom.SDO_ORDINATES.count() = 4 then
    RETURN SDO_GEOMETRY(2001,geom.sdo_srid,
    sdo_point_type(geom.SDO_ORDINATES(1), geom.SDO_ORDINATES(2), null),
    null,
    null);
    else
    return null;
    end if ;
    END getPoint;
    Sujnan

Maybe you are looking for

  • Is it possible to lock standard abap program?

    hi, i am trying to do the lock transcations. i went to sm01 and i locked se38.its working .but from pfcg its possible to go to se38(its allowing ).i want that no one can access the se38code in anyway. what can i do for this? i thought it off locking

  • User not able to print from SAP

    Hi guys,              User is not able to print from SAP. The printer is directly connected to his PC. It is not a network printer. The user is able to print at OS level perfectly. IN SP01, it shows in green and the print job has been completed succe

  • Parameters are not created for M0001 feature

    Hi Friends, During Hiring activity in IT0002 after entering all the fields, while saving i got a warning message - parameters are not created in M0001 feature. Please give me your views & answers why i got this message. Edited by: sharada vemula on A

  • Older Apple G3 'uglee' won't boot

    They are G3s, it says so right on the box. They are like nothing I've ever seen before: boxy, with perforated tops. (Hey, Appaloosa Mac Man, is this something you've seen?) It says "All In One" on the fronts, and there is a detachable rainbow Apple l

  • IDOC communication thorugh tRFC connection

    Hello All,    We all know we can communicate b/w two SAP systems by posting IDOCs using tRFC connection. I am sending one material master IDOC from 800 client to 811 client using BD10. It is getting posted successfully. Now, while transferring this d