WordPress undefined function error on using add_action() in functions.php

If add_action is undefined, it means WP is not loaded in the regular way. Assuming we are talking about functions.php in the theme folder (and not the functions.php in the wp-includes folder, which you must not mess with) there should be no problem, unless the php-file itself is run outside WP.

This could happen, for instance, if you are including the php-file with a full url, in which case WP would see it as an external source, to be evaluated outside the WP-context. In that case add_action would be undefined. Normally, this would not happen, because WP itself looks for the functions.php file in the active (child) theme, but messing up the normal way of things is certainly possible.

There is not enough context in your question to pinpoint where this could happen, but I suggest you check all include and requirestatements in your theme. Also, this may be a useful resource to track where things go wrong.