Thread: address of struct variable?

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    58

    Smile address of struct variable?

    Hi, I was wondering if anyone could tell me how to pass the address of a specific variable in a struct?

    Example:

    Code:
    typedef struct
    {
      uint8_t     A;
      uint8_t     B;
      ExtAddr_t   C;
    } stuff_t;
    
    doSomething(&stuff_t.A);
    Doing the above I get the warning: “passing argument 1 of 'doSomething‘ from incompatible pointer type”

    Any pointers would be greatly appreciated

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    More like:
    Code:
    stuff_t stuff;
    doSomething(&stuff.A);
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    The first does not compile since you can't take something from a blueprint.
    Anyway, if you'd follow laserlight's advice and make doSomething take a uint8_t* pointer, then it should work fine.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Converting from C to C++
    By Taka in forum C++ Programming
    Replies: 5
    Last Post: 04-08-2009, 02:16 AM
  2. Global Variables
    By Taka in forum C Programming
    Replies: 34
    Last Post: 11-02-2007, 03:25 AM
  3. DX - CreateDevice - D3DERR_INVALIDCALL
    By Tonto in forum Game Programming
    Replies: 3
    Last Post: 12-01-2006, 07:17 PM
  4. Replies: 16
    Last Post: 10-29-2006, 05:04 AM
  5. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM