Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

UNIX enhancements aren't.


devel / comp.lang.c / Compile time fingerprint for struct

SubjectAuthor
* Compile time fingerprint for structThiago Adams
+* Re: Compile time fingerprint for structThe Real Non Homosexual
|`- Re: Compile time fingerprint for structThiago Adams
+- Re: Compile time fingerprint for structÖö Tiib
`* Re: Compile time fingerprint for structPhilipp Klaus Krause
 +- Re: Compile time fingerprint for structThiago Adams
 `- Re: Compile time fingerprint for structThiago Adams

1
Compile time fingerprint for struct

<034d8d88-a84c-4dab-b7fc-583278492ff6n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16685&group=comp.lang.c++#16685

  copy link   Newsgroups: comp.lang.c
 by: Thiago Adams - Wed, 26 May 2021 14:58 UTC

The problem/motivation:

struct X{
char * s;
};

I want to _Static_assert in some point of my code, that
I wrote that code for some specific struct, and if this
struct changes I receive an error in compiler time.

_Static_assert (FINGERPRINT(struct X) != CURRENT_FINGERPRINT, "review this code");
free(pX->s);
free(pX);

Ideas to make this practical?
I was thinking about sizeof. One disadvantage is that
it has different finger prints depending on the platform.

Removing item, like deleting s is generally safe because we
need to review the code that stopped to compile.
The problem is when we add something and this also need to
be cleared for instance.

Re: Compile time fingerprint for struct

<bc8822e0-2614-46c6-9dd8-dc0f2a0941cdn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16722&group=comp.lang.c++#16722

  copy link   Newsgroups: comp.lang.c
 by: The Real Non Homosex - Thu, 27 May 2021 12:31 UTC

On Wednesday, May 26, 2021 at 7:58:36 AM UTC-7, Thiago Adams wrote:
> The problem/motivation:
>
> struct X{
> char * s;
> };
>
> I want to _Static_assert in some point of my code, that
> I wrote that code for some specific struct, and if this
> struct changes I receive an error in compiler time.
>
> _Static_assert (FINGERPRINT(struct X) != CURRENT_FINGERPRINT, "review this code");
> free(pX->s);
> free(pX);
>
> Ideas to make this practical?
> I was thinking about sizeof. One disadvantage is that
> it has different finger prints depending on the platform.
>
> Removing item, like deleting s is generally safe because we
> need to review the code that stopped to compile.
> The problem is when we add something and this also need to
> be cleared for instance.

You're still a dumbass that needs to be banned from using a computer.

Re: Compile time fingerprint for struct

<4ead5be3-145e-451b-8308-a576be5479b7n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16741&group=comp.lang.c++#16741

  copy link   Newsgroups: comp.lang.c
 by: Thiago Adams - Thu, 27 May 2021 22:41 UTC

On Thursday, May 27, 2021 at 9:32:08 AM UTC-3, The Real Non Homosexual wrote:
> On Wednesday, May 26, 2021 at 7:58:36 AM UTC-7, Thiago Adams wrote:
> > The problem/motivation:
> >
> > struct X{
> > char * s;
> > };
> >
> > I want to _Static_assert in some point of my code, that
> > I wrote that code for some specific struct, and if this
> > struct changes I receive an error in compiler time.
> >
> > _Static_assert (FINGERPRINT(struct X) != CURRENT_FINGERPRINT, "review this code");
> > free(pX->s);
> > free(pX);
> >
> > Ideas to make this practical?
> > I was thinking about sizeof. One disadvantage is that
> > it has different finger prints depending on the platform.
> >
> > Removing item, like deleting s is generally safe because we
> > need to review the code that stopped to compile.
> > The problem is when we add something and this also need to
> > be cleared for instance.
> You're still a dumbass that needs to be banned from using a computer.

You didn't said that... But I agree this kind of post is unusual.

But sometimes there is a compiler extensions or someone can
have an idea about it, we never known without asking.

This kind of question does not necessarily needs an answer, but
it can generate other useful discussions.

Re: Compile time fingerprint for struct

<6b23ad66-bb53-484c-9484-1f95f43aadc4n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16785&group=comp.lang.c++#16785

  copy link   Newsgroups: comp.lang.c
 by: Öö Tiib - Sun, 30 May 2021 02:27 UTC

On Wednesday, 26 May 2021 at 17:58:36 UTC+3, Thiago Adams wrote:
> The problem/motivation:
>
> struct X{
> char * s;
> };
>
> I want to _Static_assert in some point of my code, that
> I wrote that code for some specific struct, and if this
> struct changes I receive an error in compiler time.
>
> _Static_assert (FINGERPRINT(struct X) != CURRENT_FINGERPRINT, "review this code");

Source code is not tool to enforce development processes.
Source code is design and low level specification of program.
Development process like reviews should be achieved
with something else.

Re: Compile time fingerprint for struct

<s99nhq$4ra$1@solani.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16816&group=comp.lang.c++#16816

  copy link   Newsgroups: comp.lang.c
 by: Philipp Klaus Krause - Thu, 3 Jun 2021 04:58 UTC

Am 26.05.21 um 16:58 schrieb Thiago Adams:
> The problem/motivation:
>
> struct X{
> char * s;
> };
>
> I want to _Static_assert in some point of my code, that
> I wrote that code for some specific struct, and if this
> struct changes I receive an error in compiler time.
>
> _Static_assert (FINGERPRINT(struct X) != CURRENT_FINGERPRINT, "review this code");
> free(pX->s);
> free(pX);
>
> Ideas to make this practical?
> I was thinking about sizeof. One disadvantage is that
> it has different finger prints depending on the platform.
>
> Removing item, like deleting s is generally safe because we
> need to review the code that stopped to compile.
> The problem is when we add something and this also need to
> be cleared for instance.
>

Maybe you can use check for the last member still being the last?
Something like

struct X {
...
type originally_the_last_member;
}

static_assert (sizeof(X) == offsetof(X, originally_the_last_member) +
sizeof (type));

should work unless there is padding after the last member. Maybe the
apdding can be accounted for usingf some term using alignof?

Philipp

Re: Compile time fingerprint for struct

<815679b0-1463-4bba-b580-c7997cd93360n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16832&group=comp.lang.c++#16832

  copy link   Newsgroups: comp.lang.c
 by: Thiago Adams - Fri, 4 Jun 2021 18:27 UTC

On Thursday, June 3, 2021 at 1:58:47 AM UTC-3, Philipp Klaus Krause wrote:
> Am 26.05.21 um 16:58 schrieb Thiago Adams:
> > The problem/motivation:
> >
> > struct X{
> > char * s;
> > };
> >
> > I want to _Static_assert in some point of my code, that
> > I wrote that code for some specific struct, and if this
> > struct changes I receive an error in compiler time.
> >
> > _Static_assert (FINGERPRINT(struct X) != CURRENT_FINGERPRINT, "review this code");
> > free(pX->s);
> > free(pX);
> >
> > Ideas to make this practical?
> > I was thinking about sizeof. One disadvantage is that
> > it has different finger prints depending on the platform.
> >
> > Removing item, like deleting s is generally safe because we
> > need to review the code that stopped to compile.
> > The problem is when we add something and this also need to
> > be cleared for instance.
> >
> Maybe you can use check for the last member still being the last?
> Something like
>
> struct X {
> ...
> type originally_the_last_member;
> }
>
> static_assert (sizeof(X) == offsetof(X, originally_the_last_member) +
> sizeof (type));
>
> should work unless there is padding after the last member. Maybe the
> apdding can be accounted for usingf some term using alignof?
>
> Philipp

Interesting!

Re: Compile time fingerprint for struct

<6ccd2b9a-0f76-9b66-c561-3881feaf9dfa@gmail.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16943&group=comp.lang.c++#16943

  copy link   Newsgroups: comp.lang.c
 by: Thiago Adams - Thu, 10 Jun 2021 13:11 UTC

Philipp Klaus Krause wrote:
> Am 26.05.21 um 16:58 schrieb Thiago Adams:
>> The problem/motivation:
>>
>> struct X{
>> char * s;
>> };
>>
>> I want to _Static_assert in some point of my code, that
>> I wrote that code for some specific struct, and if this
>> struct changes I receive an error in compiler time.
>>
>> _Static_assert (FINGERPRINT(struct X) != CURRENT_FINGERPRINT, "review this code");
>> free(pX->s);
>> free(pX);
>>
>> Ideas to make this practical?
>> I was thinking about sizeof. One disadvantage is that
>> it has different finger prints depending on the platform.
>>
>> Removing item, like deleting s is generally safe because we
>> need to review the code that stopped to compile.
>> The problem is when we add something and this also need to
>> be cleared for instance.
>>
>
> Maybe you can use check for the last member still being the last?
> Something like
>
> struct X {
> ...
> type originally_the_last_member;
> }
>
> static_assert (sizeof(X) == offsetof(X, originally_the_last_member) +
> sizeof (type));
>
> should work unless there is padding after the last member. Maybe the
> apdding can be accounted for usingf some term using alignof?

If I check for the last member it will not detect if I add
some member before it.

I can also check for the first, in this it will not detect if
I add something in the middle.

Maybe for small structs, this alternative can be practical.

struct X
{ char first;
int middle;
char* last;
};

#define STRUCT_WAS(T, LIST) _Static_assert(sizeof(T) == sizeof(struct
_dummy LIST ), "review")

int main()
{ STRUCT_WAS(struct X, {char first; int middle; char* last; });
}

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor