Error "cannot convert parameter 1 from 'char *' to 'char' "

Hi guys, I've got a problem with a VS2008 project.
This project consists of 13 header files and of 12 cpp file.
I've created a procedure in a cpp file called PCA.cpp.

This is the content of the file:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "stdafx.h"
#include "alglibinternal.h"
#include "alglibmisc.h"
#include "ap.h"
#include "dataanalysis.h"
#include "gauss.h"
#include "linalg.h"
#include "optimization.h"
#include "solvers.h"
#include "specialfunctions.h"
#include "statistics.h"
#include <tiffio.h>

using namespace std;
using namespace alglib;
using namespace alglib_impl;

void Princ(char img1[30], char img2[30], char img3[30], char img4[30])
{
	//remove(argv[5]);

	TIFF *tif1, *tif2, *tif3, *tif4;
	
	tif1 = TIFFOpen(img1, "r");
	tif2 = TIFFOpen(img2, "r");
	tif3 = TIFFOpen(img3, "r");
	tif4 = TIFFOpen(img4, "r");

        // ... others parts of code, but img1 img2 img3 img4 will no longer be used

}


Header files that I've included are needed to solve some function used in Princ procedure.

In the main file called pcasogl.cpp I wrote:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include "gauss.h"
#include <malloc.h>
#include <stdlib.h>
#include <fstream>
#include <cstdio>

using namespace std;

extern void Princ(char, char, char, char);

// main program
int main(int argc, char *argv[])
{
     // .....

     Princ(argv[1],argv[2],argv[3],argv[4]);

     // .....
}


where in the .bat file argv[1], argv[2], argv[3], argv[4] are the names of the image I want to open.

Compiling I receive this error:

1>c:\users\...\pcasogl.cpp(46) : error C2664: 'Princ' : cannot convert parameter 1 from 'char *' to 'char'


The strange thing is that if I copy the content of PCA.cpp file in the main file it works perfectly, so probably it's a problem with the "extern" called.

Thanks so much to anyone who will try to help me.
Last edited on
so probably it's a problem with the "extern" called.
No. extern is just unnecessary for a function (but it seems to compile).

look at your prototype: void Princ(char, char, char, char);
and now how you implemented it: void Princ(char img1[30], char img2[30], char img3[30], char img4[30])
extern void Princ(char, char, char, char);


Yes, char is not equal to char[]. Try maybe:

Nice catch on the extern function prototype coder777.
Last edited on
extern is just unnecessary for a function


I didn't know that. Yes, it compiles however.

char is not equal to char[]


Thank you, that is the problem. Excuse me for my inexperience.



Topic archived. No new replies allowed.