Я столкнулся с той же проблемой на своей машине Windows и решил ее решить, установив пакет numpy + mkl из http://www.lfd.uci.edu/~gohlke/pythonlibs/ . После установки перезапустите оболочку.
Как уже упоминалось, вы можете удалить свой макрос BASE
, поскольку операторы отменяют указатели.
Я немного прояснил и исправил ваш код и объяснил, где вы идете не так:
#include <stdio.h>
#include <string.h>
struct animal
{
int walk;
int hear;
};
struct bird
{
struct animal *base;
int fly;
};
void display(struct animal *common)
{
printf("All animal details hear=%d walk=%d\n",common->hear, common->walk);
}
int main()
{
struct bird peacock; // removed ptr suffix, since it is not a pointer
struct animal base ;
base.hear=1;
base.walk=1;
peacock.base= &base;
struct bird *peacockptr = &peacock;
peacockptr->fly=1;
printf("base address using peacock struct %p\n", (void *)*(struct animal **)peacockptr); //This is the address of base using peackockptr
printf("base address animal %p\n", (void *)&base); //This is the address of base
display(&base);
display(*(struct animal **)peacockptr);
return 0;
}
Обратите внимание, что адрес peackock
равен адресу первого элемента структуры, который является struct animal *
. Поэтому вы должны привести peacockptr
к struct animal **
(потому что он указывает на первый элемент типа struct animal *
), а затем разыменовать его, чтобы получить адрес base
.