linking trouble

hridyansh thakur hridyanshthakur at gmail.com
Thu Sep 6 16:03:13 UTC 2018


i am on windows i have tried
DMD
LDC

and i am getting same linking error with linking my c++ object

i am doing by the official tutorial (dlang spec book)

here is my app.d code

import std.stdio;

void main()
{
	//writeln("Edit source/app.d to start your project.");
	int[] m = someFUN(44,55);
	ulong k = m.length;

	for (int i=0;i<k;i++)
	writeln(m[i]);


}

auto someFUN(int j , int k){
	int[] some = new int[j];

	for (int i =0 ; i<j ; i++)
		some[i] =  i;

		return some ;
}

extern(C++){int*file_io}


here is the C++ code

#include <iostream>
#include <stdio.h>
#include <stdlib.h>

FILE *fp;

int*file_io(){

char name[20] ;

std::cout << "please enter the file name " << '\n';
std::cin >> name;

   fp = fopen(name,"r+");
  char  a  = 'a';
   int  n  =  0 ;
   while (!feof(fp)) {
     a = fgetc(fp);
     if (a=='\n') {
       n++;
     }
   }

  int *p  = (int*)calloc(n,sizeof(int));
  for (size_t i = 0; i < n ; i++) {
    fscanf(fp,"%d",(p+i));
  }

return p;

}





More information about the Digitalmars-d-learn mailing list