我有一行查询:
DECLARE VARIABLE var_SecondsOfTime INTEGER;
Run Code Online (Sandbox Code Playgroud)
但运行查询后,我收到此消息:
引擎错误(代码= 335544569):动态SQL错误.SQL错误代码= -104.令牌未知 - 第1行,第9列.VARIABLE.
SQL错误(代码= -104):令牌无效.
我在互联网上随处可见,所有的例子都显示了我正在使用的相同的声明风格.
怎么了?
为什么以下代码不能按预期工作?
void foobar(int);
#ifndef foobar
printf("foobar exists");
#endif
Run Code Online (Sandbox Code Playgroud)
它总是打印信息; 它显然无法检测到一个函数作为一个实体的存在.(这是一个过载的问题吗?)
为什么不能#ifdef(或其变体)检测函数声明?声明应该在预处理时提供,所以它应该有效,不应该吗?如果没有,是否有替代方案或解决方法?
我来自Python,我在管理c ++类型方面遇到了一些问题.在Python中,我可以这样做:
if condition_is_true:
x=A()
else:
x=B()
Run Code Online (Sandbox Code Playgroud)
在程序的其余部分,我可以使用x而不关心x的类型,因为我使用具有相同名称和参数的方法和成员变量(不必使A和B具有相同的基类).现在在我的C++代码中,A类型对应于
typedef map<long, C1> TP1;
Run Code Online (Sandbox Code Playgroud)
和B到:
typedef map<long, C2> TP2;
Run Code Online (Sandbox Code Playgroud)
哪里:
typedef struct C1
{
char* code;
char* descr;
int x;
...
}
Run Code Online (Sandbox Code Playgroud)
和
typedef struct C2
{
char* code;
char* other;
int x;
...
}
Run Code Online (Sandbox Code Playgroud)
C1和C2有类似的成员,在我所说的代码部分中我只需要使用具有相同名称/类型的代码
我想做的事情如下:
if (condition==true)
{
TP1 x;
}
else
{
TP2 x;
}
Run Code Online (Sandbox Code Playgroud)
c ++中的正确方法是什么?
提前致谢
/me/home/file1.c containes function definition:
int mine(int i)
{
/* some stupidity by me */
}
Run Code Online (Sandbox Code Playgroud)
我已经宣布了这个功能
/me/home/file1.h
int mine(int);
Run Code Online (Sandbox Code Playgroud)
如果我想使用此功能mine()在/me/home/at/file2.c
为此,我需要做的就是:
file2.c
#include "../file1.h"
Run Code Online (Sandbox Code Playgroud)
够了吗?可能不是.
做完这么多,当我编译时file2.c,我得到了undefined reference to 'mine'
java中这两个数组声明语法之间有什么区别吗?
int[] variableName;
Run Code Online (Sandbox Code Playgroud)
和
int variableName[];
Run Code Online (Sandbox Code Playgroud)
哪一个更受欢迎?
在重构一些代码时,我偶然发现了这个奇怪的问题.在不影响整个类的情况下,似乎无法控制初始化程序的strictfp属性.例:
public class MyClass {
public final static float[] TABLE;
strictfp static { // this obviously doesn't compile
TABLE = new float[...];
// initialize table
}
public static float[] myMethod(float[] args) {
// do something with table and args
// note this methods should *not* be strictfp
}
}
Run Code Online (Sandbox Code Playgroud)
从JLS开始,第8.1.1.3节我认为如果使用strictfp修饰符声明类,初始化器将是strictfp .但它也说它使所有方法隐含严格:
strictfp修饰符的作用是使类声明中的所有float或double表达式(包括在变量初始化器,实例初始值设定项,静态初始化器和构造函数中)都是明确的FP-strict(第15.4节).
这意味着在类中声明的所有方法以及在类中声明的所有嵌套类型都是隐式strictfp.
因此,静态初始值设定项不接受修饰符,当应用于整个类时,一切都变为strictfp?由于strictfp关键字没有反面,这是不可能实现的?
那么,我是否使用静态方法来保持初始化程序块的主体以实现对strictfp'dness的精确控制?
我在VS2013中开发了一个包含Typescript文件的库.文件正确编译为js文件(AMD).
我想要的是为这个lib创建一个声明文件.但
tsc --declaration --module AMD --out out.d.ts [files.ts]
不起作用.
有人可以带我走正确的道路吗?
使用TypeScript 0.9.1.1.
我在PL/SQL中有一个函数:
FUNCTION do_something
RETURN BOOLEAN
IS
...
BEGIN
...
END
Run Code Online (Sandbox Code Playgroud)
这个函数可以这样调用:
DECLARE
answer BOOLEAN;
BEGIN
answer := do_something();
END
Run Code Online (Sandbox Code Playgroud)
现在,有些情况下,我不需要返回的布尔值.如果我不想得到它,只需写:
do_something();
Run Code Online (Sandbox Code Playgroud)
我得到了PLS-00306(调用DO_SOMETHING时参数类型的数量错误)有没有办法在不声明和设置新布尔值的情况下调用它,在这种情况下我永远不会使用它?
在代码审查中,我要求使用下面的选项(1),因为它导致创建符号(用于调试),而(2)和(3)似乎至少对gcc和icc没有这样做.但是(1)不是真正的const,不能在所有编译器上用作数组大小.有没有更好的选项,包括调试符号,真的是C的常量?
符号:
gcc f.c -ggdb3 -g ; nm -a a.out | grep _sym
0000000100000f3c s _symA
0000000100000f3c - 04 0000 STSYM _symA
Run Code Online (Sandbox Code Playgroud)
码:
static const int symA = 1; // 1
#define symB 2 // 2
enum { symC = 3 }; // 3
Run Code Online (Sandbox Code Playgroud)
GDB输出:
(gdb) p symA
$1 = 1
(gdb) p symB
No symbol "symB" in current context.
(gdb) p symC
No symbol "symC" in current context.
Run Code Online (Sandbox Code Playgroud)
而为了完整性,来源:
#include <stdio.h>
static const int symA = 1;
#define symB …Run Code Online (Sandbox Code Playgroud) 我可以这样迭代C风格的数组:
char foo[3] = { 'a', 'b', 'c' };
for (auto it = std::begin(foo); it != std::end(foo); ++it)
{
*it = 'k'; //values of foo are correctly modified
}
Run Code Online (Sandbox Code Playgroud)
现在假设我想包装类内部数组,暴露begin()和end()返回相对迭代方法.我尝试了以下方法:
template<size_t size>
class StackMemPolicy
{
private:
char mem[size];
public:
typedef typename std::iterator<std::input_iterator_tag, char> iter;
iter begin()
{
return std::begin(mem);
}
iter end()
{
return std::end(mem);
}
}
Run Code Online (Sandbox Code Playgroud)
似乎返回的类型声明是错误的,并且以下调用代码不编译:
StackMemPolicy<4> bar;
for (auto it = bar.begin(); it != bar.end(); ++it)
{
*it = 'k';
}
Run Code Online (Sandbox Code Playgroud)
错误如下:
错误1错误C2678:binary'!=':找不到运算符,它接受类型为'StackMemPolicy …
declaration ×10
c ×3
arrays ×2
c++ ×2
function ×2
java ×2
types ×2
variables ×2
coding-style ×1
const ×1
firebird ×1
firebird2.5 ×1
header-files ×1
iterator ×1
oracle ×1
plsql ×1
return-value ×1
scope ×1
strictfp ×1
tsc ×1
typescript ×1