0

I am creating DLL using VC++ - Console application..

I am writing it for crating a new file... I am using Createfile function for this. but facing below error...

error C2733: second C linkage of overloaded function 'CreateFileW' not allowed

Below is my .CPP file from the project..

#include "stdafx.h"
#define DLL extern "C" __declspec(dllexport)
/*
//file handle
HANDLE hFile;
//something to contain the number of bytes read
DWORD dwNumWritten;
//a boolean test variable, to test for success of reads
BOOL bTest;
//a buffer… can actually be of any type
DWORD dwBuffer[256];

hFile = CreateFile("D:\\myfile.txt", GENERIC_WRITE, FILE_SHARE_WRITE,
                NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
*/

DLL int CreateFile(char *path)
{ [COLOR="Red"]facing error at this line[/COLOR]
int i;
HANDLE hPort = CreateFile(TEXT("COM1"), GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
return i; 
}

Edited by mike_2000_17: Fixed formatting

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by ranejitendra
0

Because you're using C linkage, you cannot create overloaded functions. There already is a function CreateFile, so you can't write another one. Rename your function DLL int CreateFile(char *path).

Edited by Moschops: n/a

0

Thanks for solution

Because you're using C linkage, you cannot create overloaded functions. There already is a function CreateFile, so you can't write another one. Rename your function DLL int CreateFile(char *path).

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.