How do I write a macro that dynamically defines a public or private function?

In your second example, you seem to have lost the quote blocks around the macro definitions, which is probably the source of your problems.