troubleshooting Question

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

Avatar of GCartopel
GCartopel asked on
CMicrosoft Legacy OS
5 Comments1 Solution2436 ViewsLast Modified:

Im building a dll with MVC++ 6.0, however when I build the project I got the next message:

--------------------Configuration: TcpDll - Win32 Debug--------------------
C:\Program Files\Microsoft Visual Studio\MyProjects\TcpDll\TcpDll.cpp(78) : error C2733: second C linkage of overloaded function 'Imprime' not allowed
        C:\Program Files\Microsoft Visual Studio\MyProjects\TcpDll\TcpDll.cpp(77) : see declaration of 'Imprime'
Error executing cl.exe.

TcpDll.dll - 1 error(s), 0 warning(s)

The code is the next:

// TcpDll.cpp : Defines the initialization routines for the DLL.
#include "stdafx.h"
#include "TcpDll.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
CTcpDllApp theApp;

extern "C"
int WINAPI Imprime(char IP[14], char BUFFER[8])
      int RESULTADO;
      WSADATA data;
      SOCKET sock;
      struct linger Linger;
      struct sockaddr_in addr;
      /* Initialize windows socket */
      WSAStartup(0x0101, &data);
      /* Create socket */
      if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) {
            fprintf(stderr, "Error socket(): %d\n", WSAGetLastError());
      /* Set connection timeout */
      Linger.l_onoff = 1;
      Linger.l_linger = 60;
      setsockopt(sock, SOL_SOCKET, SO_LINGER, (char*)&Linger, sizeof(struct linger));
      /* initialize the parameter */
      memset(&addr, 0, sizeof(addr));
      addr.sin_family = AF_INET;
      addr.sin_port = htons(9100);
      addr.sin_addr.s_addr = inet_addr(IP);
      /* connect */
      if (connect(sock, (struct sockaddr*)&addr, sizeof(addr)) < 0) {
            fprintf(stderr, "Error connect(): %d\n", WSAGetLastError());
      /* send data */
      send(sock, BUFFER, 8, 0);
      /* gracefully close */
      shutdown(sock, 1);/* SD_SEND */
      while (1) {
      char buf[64];
      int n = recv(sock, buf, 64, 0);
      if (n = SOCKET_ERROR || n == 0)
      } shutdown(sock, 2);/* SD_BOTH */
      /* close socket */
      return (RESULTADO);

; TcpDll.def : Declares the module parameters for the DLL.
LIBRARY      "TcpDll"
DESCRIPTION  'TcpDll Windows Dynamic Link Library'

// TcpDll.h : main header file for the TCPDLL DLL
#if !defined(AFX_TCPDLL_H__218CC154_9176_4972_A4B2_451D6DC15936__INCLUDED_)
#define AFX_TCPDLL_H__218CC154_9176_4972_A4B2_451D6DC15936__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifndef __AFXWIN_H__
      #error include 'stdafx.h' before including this file for PCH
#include "resource.h"            // main symbols
      #include "stdio.h"
      #include "winsock.h"
class CTcpDllApp : public CWinApp
#ifdef __cplusplus
extern "C" {
int Imprime(char, char);
#ifdef __cplusplus

I test the code, building an .exe file before and the app works very well.

Please your support.


Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros