diff --git a/doc/user.tex b/doc/user.tex index f9e0e27e7..b52163699 100644 --- a/doc/user.tex +++ b/doc/user.tex @@ -216,7 +216,8 @@ the negative and positive directions of each dimension). \\\\ \begin{routine} {void ops\_decl\_const(char const * name, int dim, char const * type, T * data )} {This routine defines a global constant: a variable in global scope. Global constants need to be declared upfront so that they can be correctly handled for different parallelizations. For e.g CUDA on GPUs. Once defined - they remain unchanged throughout the program, unless changed by a call to ops\_update\_const(..) } + they remain unchanged throughout the program, unless changed by a call to ops\_update\_const(..). The ``name'' and ``type'' + parameters \emph{must} be string literals since they are used in the code generation step } \item[name] a name used to identify the constant \item[dim] dimension of dataset (number of items per element) diff --git a/ops_translator/c/ops.py b/ops_translator/c/ops.py index df4a3a962..acdfcdb4d 100755 --- a/ops_translator/c/ops.py +++ b/ops_translator/c/ops.py @@ -220,6 +220,14 @@ def ops_decl_const_parse(text, macro_defs): return args[1] = evaluate_macro_defs_in_string(macro_defs, args[1]) + if args[0].count('"') != 2: + print('Error in ops_decl_const : name must be a string literal') + return + + if args[2].count('"') != 2: + print('Error in ops_decl_const : type must be a string literal') + return + consts.append({ 'loc': m.start(), 'name': args[0].strip(),