logo
down
shadow

Invalid initializer when using gettext in a structure


Invalid initializer when using gettext in a structure

By : Shuvam Ghosh
Date : November 17 2020, 01:00 AM
it helps some times I want to create a multiple array of my structure: , Just change the struct definition to
code :
typedef struct  {
    const gchar *icon_name;
    int response;
    const gchar *label;
} button_data;
button_data b[3] = {
    { "dialog-ok", GTK_RESPONSE_YES, _("Yes")  },
    { "dialog-close", GTK_RESPONSE_NO, _("No") },
    { NULL, 0, NULL }
};
for (index = 0; b[index].icon_name != NULL; index++)
const button_data b[] = {
    { "dialog-ok", GTK_RESPONSE_YES, _("Yes")  },
    { "dialog-close", GTK_RESPONSE_NO, _("No") },
    { NULL, 0, NULL }
};


Share : facebook icon twitter icon
php gettext directory structure on different environments

php gettext directory structure on different environments


By : Sanjay Gupta
Date : March 29 2020, 07:55 AM
I wish did fix the issue. If you're running your code on Linux, gettext works only with locales already installed on the OS. This means that if you set the locale to en_GB then if the only installed locale is en_GB.utf8 or en_US, then you don't get the translations.
Try this on both of your environments and compare the results:
code :
locale -a
en_US
en_US.ISO8859-1
en_US.ISO8859-15
en_US.US-ASCII
en_GB
en_GB.utf8
de_DE

de_DE.utf8
C
POSIX
sudo localedef -c -i en_US -f UTF-8 en_US.utf8
sudo localedef -c -i en_GB -f UTF-8 en_AU
sudo localedef -c -i en_GB -f UTF-8 en_AU.utf8
<?php

    // Set language to German
    putenv('LC_ALL=de_DE.utf8');
    setlocale(LC_ALL, 'de_DE.utf8');

    // Specify location of translation tables
    bindtextdomain("myPHPApp", "./locale");

    // Choose domain
    textdomain("myPHPApp");

    // Translation is looking for in ./locale/de_DE.utf8/LC_MESSAGES/myPHPApp.mo now

    // Print a test message
    echo gettext("Welcome to My PHP Application");

    // Or use the alias _() for gettext()
    echo _("Have a nice day");

?>
<?php

  // Set language to German written in Latin-1
  putenv('LC_ALL=de_DE.ISO8859-1');
  setlocale(LC_ALL, 'de_DE.ISO8859-1');

?>
Given a pointer to a structure, can I assign the structure the result of an aggregate-initializer in one line?

Given a pointer to a structure, can I assign the structure the result of an aggregate-initializer in one line?


By : Arnab Haque
Date : March 29 2020, 07:55 AM
With these it helps Yes, you can using the compound literals syntax:
code :
#include <stdio.h>

typedef struct {
  int a, b;
} S;

int main(void) {
    S s;
    S *p = &s;

    *p = (S){1,2};

    printf("%d %d\n", p->a, p->b);
    return 0;
}
Structure initialization error: could not convert from ‘<brace-enclosed initializer list>’ to structure

Structure initialization error: could not convert from ‘<brace-enclosed initializer list>’ to structure


By : Bala
Date : March 29 2020, 07:55 AM
this will help Looks like you are using c++11, but not yet c++14.
Once you provide default member initializers, the class is no longer an aggregate, and you cannot use aggregate initialization.
invalid initializer

invalid initializer


By : newbie2614
Date : March 29 2020, 07:55 AM
will help you Your initializer of the array with a C string is invalid. The good news is that you do not need it at all:
C: why do I get invalid initializer?

C: why do I get invalid initializer?


By : Ruben R H
Date : March 29 2020, 07:55 AM
it helps some times What you are attempting to do is not initialization but assignment. The former is done at the time the variable is defined, while the later is done later as an executable statement. You're getting an error because executable statements are not allowed outside of a function.
You need to use an initializer at the time the arrays are defined:
Related Posts Related Posts :
  • Having malloced some memory,I could't calculator the proper size of the memories I malloced.I don't know why
  • What is the main difference between integer pointer and character pointer?
  • Why are some functions declared extern and header file not included in source in Git source code?
  • what is the use of fflush(stdin) in c programming
  • Is it safe to return file File descriptor locally allocated from another function In C
  • Changing undefined values of an array
  • What does an empty parameter list mean?
  • using strtol on a string literal causing segmentation fault
  • Same structure objects memory overlap?
  • C-Linux-Any way to pass command "history" to Linux shell?
  • Using #define in defining string size C
  • How to use thread pool and message queues in Multithreaded Matrix Multiplication?
  • Can't find how to select path to run a C program
  • Automatic variable in C not initialized but given fixed value within loop
  • main() function defined without return type gives warning
  • Output of following code with integer, float, char variable
  • why buffer memory allocation error in opencl
  • Why am I getting this error during run-time?
  • Strange behaviour of the pow function
  • task in increment , decrement , printf() , why these are evaluated in this manner in C
  • 28 extra bytes in bss
  • Waiting for multiple events without polling
  • Why are my variables reporting as "undeclared identifier" when compiling?
  • Correct AddNode function but somehing happens when I printf
  • When I traverse in the splay tree, then now which one is root?
  • Data type conversion in Postfix evaluation
  • No output in terminal (Head First C)
  • Data writes over after realloc
  • function: findnextchar() doesn't work
  • Getting file-size property from Nautilus
  • Forward declare entities in C standard library?
  • Static array in C
  • Function signature indicates return type void*, but returns pointer of a different type
  • How do I measure time per thread in C?
  • Online judgeProblem (Wrong Answer)
  • Use function pointer initialized in other source file
  • last line of file is duplicated using fscanf
  • How to print files with same month of modification using directory in c?
  • ADT Circular Queue enqueue and dequeue
  • What events can cause ferror to return non-zero?
  • Accessing dynamically allocated structure received through socket
  • Vim with C Conditional Parsing
  • C can pointers be aligned with any other data type?
  • sdcc inline asm() not working
  • I/O - Manipulation of C Strings
  • sscanf 1 byte hex data without overflow
  • Avoid division by zero in C when taking log with respect to a random number
  • C - memory corruption with threads
  • Why does my program sometimes returns 0xc0000005 and sometimes runs well?
  • C - Dynamic array handling advice
  • Does Standard define null pointer constant to have all bits set to zero?
  • valgrind report strange memory usage
  • abs without branching, why this code works
  • Heapsort Algorithm by Cormen Implementation in C , not working correctly
  • C database program can't find 1st input. Why?
  • Generate random numbers with rand() except number zero
  • How can I know how many free bits are there in a pointer?
  • Program gets 101 numbers instead of 100
  • Returning array pointer produces "warning: return from incompatible pointer type"
  • Gauss Seidel (Specific equation solver) in C
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org