Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C and D communication

Tags:

c

d

I read this in order to do my approach

I have a file: software_pluginInterface.di

Here I declare :

extern (C): void performComputation(char lib[], char func[], void* ptr[], int varNum );
// lib and func will be used later

Then I have the corresponding C file: software_pluginInterface.c, where I declare :

#include "stdio.h"
#include "string.h"

void performComputation(char lib[], char func[], void * v[], int varNum)
{

  printf("there are %d variables \n", varNum);

}

Then I call this with :

performComputation(A, B, V, to!int(v.count()/3));

A, B are '\0' terminated char arrarys V is a void pointer array with 6 elements

So I would expect a output like : there are 2 variables

But I am getting : there are 1557197040 variables

I have 64 bit OS, and I compile it all using (as in the other question)

gcc -c software_pluginInterface.c
dmd software.d software_pluginInterface.o

Then I call them using : ./software

PS: according to this page, D ints are same as C ints.

like image 808
Sean Avatar asked Aug 10 '14 19:08

Sean


People also ask

What is the D style of communication?

D – Dominance focuses on problems and challenges. I – Influence focuses on people and contacts. S – Steadiness focuses on pace and consistency. C – Conscientious focuses on procedures and constraints.

What are the 4 DISC personality types?

The DiSC model describes four main styles: D, i, S, and C. D is for Dominance, i is for Influence, S is for Steadiness, and C is for Conscientiousness. Everyone is a mixture of each style, but most people tend to fall into one or two main DiSC style quadrants.

Which DISC personality is best?

It's tempting to believe that there is one personality type that is better than the rest. However, the truth is that none of the DISC personality types is better or worse than the other.


1 Answers

In D, an array consists of a pointer to some data, and a length, in C++, it's basically just a pointer. This means that your D function should be declared as:

extern (C): void performComputation(char* lib, char* func, void** ptr, int varNum );
like image 152
Orvid King Avatar answered Nov 05 '22 23:11

Orvid King