Guest User

Untitled

a guest
Dec 11th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. #ifndef PINF_OPTS_H
  2. #define PINF_OPTS_H
  3. #endif //PINF_OPTS_H
  4.  
  5. struct _optL {
  6. struct opt avOpt[];
  7. } optL;
  8.  
  9. struct _opt {
  10. char *option; // e.g. --group
  11. char *alias; // e.g. -G
  12. int reqArg; // Require Argument | 0: No 1: Yes
  13. int maxArgs; // -1: Undefined/ Unlimited
  14. int func; /* Run Function? 0: No 1: Yes
  15. * If No, it can be checked with function 'isOptEnabled'
  16. */
  17. } opt;
  18.  
  19. struct _acOpt {
  20. struct opt *acOpt[];
  21. } acOpt;
  22.  
  23. // == FUNC ==
  24. void initOpts(void);
  25.  
  26. #include "opts.h"
  27.  
  28. #include <stdio.h>
  29. #include <stdlib.h>
  30.  
  31. // == VAR ==
  32. static struct optL *optList;
  33. static struct acOpt *activeOpts;
  34.  
  35. // == CODE ==
  36. void initOpt(void) {
  37. optList = (struct optL *)malloc(sizeof(struct optL *));
  38. activeOpts = (struct acOpt *)malloc(sizeof(struct acOpt *));
  39. }
  40.  
  41. #include <stdio.h>
  42. #include "../include/opts.h"
  43.  
  44. int main(void) {
  45. initOpts();
  46. return 0;
  47. }
  48.  
  49. In file included from include/opts.c:5:0:
  50. include/opts.h:14:16: error: array type has incomplete element type ‘struct opt’
  51. struct opt avOpt[];
  52. ^~~~~
  53. include/opts.h:28:17: error: flexible array member in a struct with no named members
  54. struct opt *acOpt[];
  55. ^~~~~
Add Comment
Please, Sign In to add comment