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

  • Home
  • SEARCH
  • 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 7007663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:38:11+00:00 2026-05-27T21:38:11+00:00

I am writing some code for a linux program I am working on that

  • 0

I am writing some code for a linux program I am working on that requires libssh. I was looking at their tutorial page and I saw that it passes all the parameters to ssh_options_set() by reference. Why is that?

#include <libssh/libssh.h> 
#include <stdlib.h>

int main()
{
  ssh_session my_ssh_session;
  int verbosity = SSH_LOG_PROTOCOL;
  int port = 22;

  my_ssh_session = ssh_new();
  if (my_ssh_session == NULL)
    exit(-1);

  ssh_options_set(my_ssh_session, SSH_OPTIONS_HOST, "localhost");
  ssh_options_set(my_ssh_session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity); //here
  ssh_options_set(my_ssh_session, SSH_OPTIONS_PORT, &port); //here

  ...

  ssh_free(my_ssh_session);
}
  • 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-27T21:38:12+00:00Added an answer on May 27, 2026 at 9:38 pm

    It’s a trick to bypass the type system.

    Since the various options that can be set are of various types, the function accepts a const void * as last argument (i.e. the option value, see the documentation) to be able to receive a pointer to any type; such pointer will be re-casted to the correct pointer type inside ssh_options_set, depending on the particular option that is being set.

    This couldn’t be done with pass by value, because there’s no “generic type” you can cast any other type to (even just for the fact that various types have various sizes – a pointer, instead, on a given architecture is always of the same size, whatever type it refers to); to solve or mitigate this problem in C++ there are overloads and templates, but here we are talking about C.

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

Sidebar

Related Questions

In my Linux system I'm writing a program that dynamically loads some .so libraries
So I was writing some code today that basically looks like this: string returnString
I'm writing some code that id like to be able to work with any
I'm writing some code that handles logging xml data and I would like to
I'm writing some code that uses dynamic shared libraries as plugins. My command line
i've been writing some OpenCL code lately on linux (ubuntu 10.4, ati catalyst 10.4
I'm writing a Linux program that currently compiles and works fine on x86 and
I'm taking my first crack at writing some linux kernel code, and I'm hitting
I'm writing some C++ code that will have to send data over TCP/IP. I
I'm writing a program in C that needs to do some fast math calculations.

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.