diff --git a/backends/GenerateC.hs b/backends/GenerateC.hs index 1209c94..933b0ae 100644 --- a/backends/GenerateC.hs +++ b/backends/GenerateC.hs @@ -165,8 +165,15 @@ cgenTopLevel headerName s tell ["#include \n"] cs <- getCompState + let isTopLevelSpec (A.Specification _ n _) + = A.nameName n `elem` (csOriginalTopLevelProcs cs) + tellToHeader $ sequence_ $ map (call genForwardDeclaration) - (listify (const True :: A.Specification -> Bool) s) + (listify isTopLevelSpec s) + -- Things like lifted wrapper_procs we still need to forward-declare, + -- but we do it in the C file, not in the header: + sequence_ $ map (call genForwardDeclaration) + (listify (not . isTopLevelSpec) s) tell ["#include \"", dropPath headerName, "\"\n"]