Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8472679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:08:35+00:00 2026-06-10T17:08:35+00:00

I need help figuring out the correct data type for an assignment from a

  • 0

I need help figuring out the correct data type for an assignment from a function call please.

I’m trying to get at the data in the content field of N_Vector u. Here’s what the documentation says about N_Vector:

The type N_Vector is defined as

N_Vector u;
tpedef struct _generic_N_Vector *N_Vector;
struct _generic_N_Vector {
  void *content;
  struct _generic_N_Vector_Ops *ops;
};

…

[The parallel NVECTOR module] defines the content field of N_Vector
to be a structure containing global and local lengths, a pointer to the
beginning of contiguous local data array, MPI communicator and flag.

struct _N_VectorContent_Parallel {
  long int local_length;
  long int global_length;
  booleantype own_data;
  realtype *data;
  MPI_Comm comm;
}

So I guess that means that content in _generic_N_Vector “points to” a structure of type _N_VectorContent_Parallel (right?).

Then I try to use a macro for accessing content. Here’s the documentation for NV_CONTENT_P.

v_cont=NV_CONTENT_P(v) sets v_cont to be a pointer to the N_Vector content
structure of type struct _N_VectorParallelContent.

Notice the different name of the struct!

What does that mean? What type do I declare v_cont to be?

I tried

N_Vector u;
...
_N_VectorParallelContent *v_cont1;
_N_VectorContent_Parallel *v_cont2;
v_cont1 = NV_CONTENT_P(u);
v_cont2 = NV_CONTENT_P(u);

but these declarations got the error “‘_N_VectorContent_Parallel’ undeclared…” or “‘_N_VectorParallelContent’ undeclared…”.

But it seems that these structures must be delcared already. I successfully declared (and used) u, of type N_Vector. And the docs seem to say that N_Vector contains one of those two structures (or maybe both).

So why the error message? What is the correct data type to declare for v_cont to receive data from NV_CONTENT_P?

I know this is a long, detailed question, but I don’t understand enough to whittle it down any more.
Thanks for your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T17:08:36+00:00Added an answer on June 10, 2026 at 5:08 pm

    I’m not familiar with this particular library, but it looks to me like the documentation is a little inconsistent.

    Right after the blurb about NV_CONTENT_P(v), it says NV_CONTENT_P(v) is defined as:

    #define NV_CONTENT_P(v) ( (N_VectorContent_Parallel)(v->content) )
    

    So that version of the name is probably correct. I can’t see a definition for N_VectorContent_Parallel on that page, but it’s probably defined somewhere as something like struct _N_VectorContent_Parallel*. So, you can probably do:

    N_VectorContent_Parallel v_cont1 = NV_CONTENT_P(u);
    

    Remember that for structs, struct is part of the type name. This means that you’re getting errors in your example because you haven’t included struct:

    // this is an unknown type
    _N_VectorParallelContent *v_cont1; 
    
    // this is a "struct _N_VectorParallelContent"
    struct _N_VectorParallelContent *v_cont1; 
    
    // But use this one, as it follows the macro
    N_VectorContent_Parallel v_cont1;
    

    If you want to see exactly what the preprocessor has done to your code, you can use gcc’s -E flag.

    -E    Stop after the preprocessing stage; do not run the compiler proper. 
       The output is in  the form of preprocessed source code, which is sent to 
       the standard output.
       Input files which don't require preprocessing are ignored.
    

    This is especially useful for seeing the results of macros and multiple complex header files.


    Edit: From the source you’ve linked:

    typedef struct _N_VectorContent_Parallel *N_VectorContent_Parallel;
    

    This is a type definition that says that N_VectorContent_Parallel is the same as a struct _N_VectorContent_Parallel * (a pointer to a struct _N_VectorContent_Parallel), which means you can access v_cont1 using the -> syntax:

    N_VectorContent_Parallel v_cont1;
    printf("%d",v_cont1->local_length);
    

    a->b is is shorthand for (*a).b – it’s just a cleaner-looking way of writing the dereference needed to accessing a member of a struct through a pointer to that struct. If that seems confusing, see my answer to this question.

    Personally, I don’t like typedefs that hide pointers like this one, because it’s hard to tell by looking at the code whether you need to use a.b or a->b.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need help figuring out how to convert data that comes in from a
I need help figuring out how to submit data from a table row into
http://jsfiddle.net/nicktheandroid/ZSvHK/ I need help figuring out how to get this right, problems listed below.
Need help figuring out how to extract text from context (Honda from str), need
I need help figuring out which Accessory Type Switch has been changed. I have
Need help figuring out a couple common workflows with Github. I come from a
I need help figuring out bits of code. I need a function that loads
Need help in figuring out a way to fetch a particular block of content
I need help figuring out the syntax for the eval function - or even
I need help figuring out why my rspec tests are running slowly. I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.