move error detection for assign to 64 bit long from snc to C compiler
Warning, cannot access the index:
_darcs/index: opening of '_darcs/index' failed: permission denied (Permission denied)
diff -rN -u old-branch-2-0/src/snc/parse.c new-branch-2-0/src/snc/parse.c
--- old-branch-2-0/src/snc/parse.c 2022-09-26 05:54:44.682331164 +0200
+++ new-branch-2-0/src/snc/parse.c 2022-09-26 05:54:44.682331164 +0200
@@ -194,22 +194,25 @@
return;
}
-int check_type_too_long(Var *vp)
+void check_type_too_long(Var *vp)
{
extern int line_num;
+ extern char *src_file;
- if ((sizeof(long) > 4 && (vp->type == V_LONG || vp->type == V_ULONG))
- || (sizeof(int) > 4 && (vp->type == V_INT || vp->type == V_UINT)))
+ if (vp->type == V_LONG || vp->type == V_ULONG)
{
- fprintf(stderr,
- "line %d: cannot assign variable >%s< because on this architecture "
- "its (base) type is larger than 4 bytes. Such variables cannot be faithfully "
- "mapped to any of the Channel Access base types.\nTry declaring the "
- "variable as 'int' or, if that is still too large on your system, as 'short'.\n",
- line_num, vp->name);
- return FALSE;
+ printf("#include <limits.h>\n");
+ print_line_num(line_num-1, src_file);
+ printf(
+"#if LONG_MAX > 0x7fffffffL\n"
+"# error "
+"cannot assign variable >%s< because on this architecture its (base) \\\n"
+"type is larger than 4 bytes. Such variables cannot be faithfully mapped \\\n"
+"to any of the Channel Access base types. Try declaring the variable \\\n"
+"as 'int' or 'unsigned int'.\n"
+"#endif\n",
+ vp->name);
}
- return TRUE;
}
/* "Assign" statement: Assign a variable to a DB channel.
@@ -245,7 +248,7 @@
return;
}
- if (!check_type_too_long(vp)) return;
+ check_type_too_long(vp);
/* Build structure for this channel */
cp = build_db_struct(vp);
@@ -290,7 +293,7 @@
return;
}
- if (!check_type_too_long(vp)) return;
+ check_type_too_long(vp);
cp = vp->chan;
if (cp == NULL)
@@ -374,7 +377,7 @@
return;
}
- if (!check_type_too_long(vp)) return;
+ check_type_too_long(vp);
/* Build a db structure for this variable */
cp = build_db_struct(vp);
patch da751ed92d645c51728e9d112b83711bf9a5a7e5
Author: benjamin.franksen@helmholtz-berlin.de
Date: Tue Apr 19 12:37:40 CEST 2011
* move error detection for assign to 64 bit long from snc to C compile