pointer cast

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Carlos F.

    #1

    pointer cast

    Hi everyboy, somebody could tell me what meen the following cast:

    a = (struct foo 8) b
    c = int (func) (int)

    Thanks

    Carlos
  • Christopher Benson-Manica

    #2
    Re: pointer cast

    Carlos F. <prohto@yahoo.c om> spoke thus:
    [color=blue]
    > a = (struct foo 8) b[/color]

    If you meant (struct foo *) b, it's pretty self explanatory - cast b
    to a foo pointer and assign it to a. Whether it results in
    well-defined behavior or not depends on what a and b are declared as
    and what's happened prior to the line in question.
    [color=blue]
    > c = int (func) (int)[/color]

    Depends on what func is, and it's probably illegal anyway unless func
    is an obfuscated macro. Post more code.

    --
    Christopher Benson-Manica | I *should* know what I'm talking about - if I
    ataru(at)cybers pace.org | don't, I need to know. Flames welcome.

    Comment

    • Karthik

      #3
      Re: pointer cast

      Carlos F. wrote:
      [color=blue]
      > Hi everyboy, somebody could tell me what meen the following cast:
      >
      > a = (struct foo 8) b[/color]
      Did u mean -
      a = (struct foo *) b

      Then you are casting pointer to type b to pointer to type a.
      [color=blue]
      > c = int (func) (int)[/color]
      Not sure with this syntax .. Do you want to check that ?


      [color=blue]
      >
      > Thanks
      >
      > Carlos[/color]


      --
      Karthik.
      Humans please 'removeme_' for my real email.

      Comment

      • CBFalconer

        #4
        Re: pointer cast

        "Carlos F." wrote:[color=blue]
        >
        > Hi everyboy, somebody could tell me what meen the following cast:
        >
        > a = (struct foo 8) b[/color]

        This is a syntax error.
        [color=blue]
        > c = int (func) (int)[/color]

        If func exists both as a functional macro, and as a callable
        function, this forces the actual function to be called. The macro
        can only be called by "func(" which this is not.

        --
        "I'm a war president. I make decisions here in the Oval Office
        in foreign policy matters with war on my mind." - Bush.
        "Churchill and Bush can both be considered wartime leaders, just
        as Secretariat and Mr Ed were both horses." - James Rhodes.


        Comment

        Working...