Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5972831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:42:49+00:00 2026-05-22T20:42:49+00:00

I ‘m writing a C-Code in which i use sockets. I use this on

  • 0

I ‘m writing a C-Code in which i use sockets. I use this on windows and on linux, so i try to write it dynamicly. I wrote two functions to get a server/client-socket. There i have an error on compiling:

debian:~/cross_socket# make
gcc *.c -Wall
i586-mingw32msvc-gcc *.c -Wall -lws2_32
socket.c: In function 'get_client_socket':
socket.c:28: warning: passing argument 3 of 'get_socket' from incompatible pointer type
socket.c:13: note: expected 'int (*)(SOCKET,  const struct sockaddr *, int)' but argument is of type 'int (*)(SOCKET,  const struct sockaddr *, int)'
socket.c: In function 'get_server_socket_addr':
socket.c:43: warning: passing argument 3 of 'get_socket' from incompatible pointer type
socket.c:13: note: expected 'int (*)(SOCKET,  const struct sockaddr *, int)' but argument is of type 'int (*)(SOCKET,  const struct sockaddr *, int)'

gcc for my local system works great, but if i use mingw i get this error?!?
It says:
I use int (*)(SOCKET, const struct sockaddr *, int) instead of int (*)(SOCKET, const struct sockaddr *, int)… ?

Here the relevant code:

inline SOCKET get_socket(uint16_t port, in_addr_t socket_in_addr, int (*create)(SOCKET, 
const struct sockaddr*, socklen_t)) {
        SOCKADDR_IN addr;
        SOCKET result_socket = GET_SOCKET;
        if (SOCKET_NOK(result_socket))
                return SOCKET_INIT_ERROR;
        memset(&addr, 0, sizeof(SOCKADDR_IN));
        addr.sin_family = AF_INET;
        addr.sin_port = htons(port);
        addr.sin_addr.s_addr = socket_in_addr;
        if (CONNECT_NOK(create(result_socket, (SOCKADDR*)&addr, sizeof(SOCKADDR))))
                return SOCKET_INIT_ERROR;
        return result_socket;
}

SOCKET get_client_socket(char* target, uint16_t port) {
        return get_socket(port, inet_addr(target), &connect);
/*      SOCKADDR_IN addr;
        SOCKET client_socket = GET_SOCKET;
        if (SOCKET_NOK(client_socket))
                return SOCKET_INIT_ERROR;
        memset(&addr,0,sizeof(SOCKADDR_IN));
        addr.sin_family = AF_INET;
        addr.sin_port = htons(port);
        addr.sin_addr.s_addr = inet_addr(target);
        if (CONNECT_NOK(connect(client_socket, (SOCKADDR*)&addr, sizeof(SOCKADDR))))
                return SOCKET_INIT_ERROR;
        return client_socket;*/
}

SOCKET get_server_socket_addr(uint16_t port, in_addr_t socket_in_addr) {
        return get_socket(port, socket_in_addr, &bind);
/*      SOCKADDR_IN addr;
        SOCKET server_socket = GET_SOCKET;
        if (SOCKET_NOK(server_socket))
                return SOCKET_INIT_ERROR;
        memset(&addr, 0, sizeof(SOCKADDR_IN));
        addr.sin_family = AF_INET;
        addr.sin_port = htons(port);
        addr.sin_addr.s_addr = socket_in_addr;
        if (CONNECT_NOK(bind(server_socket, (SOCKADDR*)&addr, sizeof(SOCKADDR_IN))))
                return SOCKET_INIT_ERROR;
        return server_socket;*/
}

Has anyone an idea?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T20:42:50+00:00Added an answer on May 22, 2026 at 8:42 pm

    Probably calling wrong convention.

    On Windows most of the API functions are defined as WINAPI, which is __stdcall, a.k.a. PASCAL. i.e. parameters are passed left-to-right, and the stack is cleaned by the callee.

    OTOH default compilation calling convention is __cdecl.

    P.S. It’d be nice if mingw printed a more detailed error information.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a text area in my form which accepts all possible characters from
Hi if i run my project its indicate this logcat error...how to solve this
Does anyone know how can I replace this 2 symbol below from the string
The problem with unsigned char. I am reading a PPM image file which has
I have just tried to save a simple *.rtf file with some websites and
I would like to count the length of a string with PHP. The string
I've got a string that has curly quotes in it. I'd like to replace
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am currently running into a problem where an element is coming back from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.