0

I am trying to understand how does ODB models work.

This is snippet from the official site:

  #pragma db object
  class person
  {
  private:
    friend class odb::access;
    person () {}

    #pragma db id
    string email_;

    string name_;
    unsigned short age_;
  };

My questions is, how can I specify these custom pragmas and then reuse them? (#pragma db object)

DevSolar
  • 67,862
  • 21
  • 134
  • 209
petomalina
  • 2,020
  • 2
  • 19
  • 25

1 Answers1

3

Any #pragma is a compiler-dependent, implementation-defined feature. Any #pragma is, and can only be, documented by the specific compiler in question.

DevSolar
  • 67,862
  • 21
  • 134
  • 209
  • And because I can never resist using this brilliant quote: *"The '#pragma' command is specified in the ANSI standard to have an arbitrary implementation-defined effect. In the GNU C preprocessor, '#pragma' first attempts to run the game 'rogue'; if that fails, it tries to run the game 'hack'; if that fails, it tries to run GNU Emacs displaying the Tower of Hanoi; if that fails, it reports a fatal error. In any case, preprocessing does not continue. **-- Richard M. Stallman, The GNU C Preprocessor, version 1.34**"* – DevSolar Mar 17 '15 at 11:48
  • why can't write #pragma into c standard? – Lei Yang Jul 24 '17 at 12:39
  • @LeiYang: They **are** in the standard -- as the way to access *compiler-dependent, implementation-defined features* (except for the standard pragmas, `#pragma STDC`, being a standard way to access specific *standard* features -- `FP_CONTRACT`, `FENV_ACCESS`, and `CX_LIMITED_RANGE`). The OP's ODB pragmas aren't standard, note that I added the link to the "official site" for them to the question. – DevSolar Jul 24 '17 at 13:21