LVS
lvs-users
Google
 
Web LinuxVirtualServer.org

Re: [PATCH] additional proc entries for synchronisation

To: lvs-users@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [PATCH] additional proc entries for synchronisation
From: Martijn Klingens <mklingens@xxxxxx>
Date: Thu, 21 Nov 2002 17:31:34 +0100
On Thursday 21 November 2002 17:11, Roberto Nibali wrote:
> I would like to learn how to get the size of a member of a struct without 
> creating an instance of the struct itself. Do you know a better way?

----
#include <stdio.h>

struct foo {
    int bar;
    int dummy;
};

int main()
{
    printf( "Size of foo: %d\n", sizeof( struct foo ) );
    printf( "Size of foo.bar: %d\n", sizeof( ( ( struct foo * ) 0 )->bar ) );

    return 0;
}
----

It's not perfect, but at least it reads better than your syntax ;-)

Oh, and of course C++ groks this perfectly:

----
#include <iostream>

using namespace std;

class foo {
public:
    int bar;
    int dummy;
};

int main()
{
    cout << "Size of foo: " << sizeof( foo ) << endl;
    cout << "Size of foo::bar: " << sizeof( foo::bar ) << endl;

    return 0;
}
----

so maybe you should switch language :-P
-- 
Martijn



<Prev in Thread] Current Thread [Next in Thread>