Q:

Is it a good practice to hide structure definition in C?

I think that hiding definition of structure makes the code safer as you enforce with the help of compiler that no member of the structure can be accessed directly. The downside is that users cannot declare variables of the structure type on stack because the size of the structure is not known, while sometimes it's desirable to avoid using malloc(). This can be (with a part-success) solved with alloca(3) which is present in all major libc implementations, although this function doesn't conform to POSIX. Given this little pros and cons, can such design generally considered good?
In lib.h:
struct foo;
extern size_t foo_size;
int foo_get_bar (struct foo *);

In lib.c:
struct foo {
  int bar;
};

size_t foo_size = sizeof foo;

int foo_get_bar (struct foo *foo)
{
  return foo->bar;
}

In example.c:
#include "lib.h"

int bar(void) {
  struct foo *foo = alloca (foo_size);
  foo_init (foo);
  return foo_get_bar (foo);
}

UPD: Updated the question, stating is explicitly that the idea of using alloca() is to be able to declare structure on stack yet hiding its definition.

A:

Yes it is good practice to hide data.
Alternate to alloca(foo_size); is to declare an aligned character array and perform pointer conversion.
The pointer conversion is not fully portable though.
The character array needs to be a VLA if the size needs to be a variable and not a compile time constant.
extern size_t size;

struct sfoo;

#include <stddef.h>

int main(void) {
   unsigned char _Alignas (max_align_t) cptr[size];
   // or unsigned char _Alignas (_Complex  long double) cptr[size];  // some widest type
   struct sfoo *sfooptr = (struct sfoo *) cptr;

If VLAs are not desired/available, declare the size as a constant like #define foo_N 100 that is certain to be at least as much as needed.

