目前,我使用以下函数模板来抑制未使用的变量警告:
template<typename T>
void
unused(T const &) {
/* Do nothing. */
}
Run Code Online (Sandbox Code Playgroud)
但是,当从Linux移植到cygwin时,我现在在g ++ 3.4.4上遇到编译器错误(在linux上我是3.4.6,所以这可能是一个bug修复?):
Write.cpp: In member function `void* Write::initReadWrite()':
Write.cpp:516: error: invalid initialization of reference of type 'const volatile bool&' from expression of type 'volatile bool'
../../src/common/Assert.h:27: error: in passing argument 1 of `void unused(const T&) [with T = volatile bool]'
make[1]: *** [ARCH.cygwin/release/Write.o] Error 1
Run Code Online (Sandbox Code Playgroud)
未使用的参数是一个声明为的成员变量:
volatile bool readWriteActivated;
Run Code Online (Sandbox Code Playgroud)
这是编译器错误还是我的代码中的错误?
这是最小的测试用例:
template<typename T>
void unused(T const &) { }
int main() {
volatile bool x = …Run Code Online (Sandbox Code Playgroud) 我正在开发一个小型TCP客户端/服务器库.
我在创建客户端并将其连接到服务器时遇到此问题.它给了我这个例外
通常只允许使用每个套接字地址(协议/网络地址/端口)
我的代码是.
public TCPClient(string remoteIPAddress, int port)
{
this.remoteIPAddress = IPAddress.Parse(remoteIPAddress);
this.port = port;
IPEndPoint remoteEndPoint = new IPEndPoint(this.remoteIPAddress, this.port);
tcpClient = new TcpClient(remoteEndPoint);
}
Run Code Online (Sandbox Code Playgroud)
这是TCPServer
public TCPServer(int listeningPort)
{
this.listeningPort = listeningPort;
tcpListenter = new TcpListener(this.listeningPort);
workers = new List<TCPServerWorker>();
this.keepRunning = false;
}
Run Code Online (Sandbox Code Playgroud)
任何帮助,为什么我得到这个例外
我正在尝试加密/解密XML文件.我发现这个样本用于加密但我不知道如何解密?任何的想法?谢谢!
// Load this XML file
System.Xml.XmlDocument myDoc = new System.Xml.XmlDocument();
myDoc.Load(@"c:\persons.xml");
// Get a specified element to be encrypted
System.Xml.XmlElement element = myDoc.GetElementsByTagName("Persons")[0] as System.Xml.XmlElement;
// Create a new TripleDES key.
System.Security.Cryptography.TripleDESCryptoServiceProvider tDESkey = new System.Security.Cryptography.TripleDESCryptoServiceProvider();
// Form a Encrypted XML with the Key
System.Security.Cryptography.Xml.EncryptedXml encr = new System.Security.Cryptography.Xml.EncryptedXml();
encr.AddKeyNameMapping("Deskey", tDESkey);
// Encrypt the element data
System.Security.Cryptography.Xml.EncryptedData ed = encr.Encrypt(element, "Deskey");
// Replace the existing data with the encrypted data
System.Security.Cryptography.Xml.EncryptedXml.ReplaceElement(element, ed, false);
// saves the xml file with …Run Code Online (Sandbox Code Playgroud) 我是R的新手,并且很难将来自各种来源的信息拼凑起来,这些信息与编写R代码的"好"做法有关.我已经阅读了基本指南,但我一直很难找到最新的信息.
我正在创建一个MSBuild任务,它将读取特定注册表项的注册表.如果我在控制台应用程序中编写相同的代码行(见下文),它将返回预期的结果,但是当它在MSBuild任务中时,它不返回任何内容.
Return Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Setup\", "SQLPath", Nothing)
Run Code Online (Sandbox Code Playgroud)
Nothing如果键/值对不存在,我希望上面的代码返回,如果它存在,则返回值.我Nothing在MSBuild任务执行时得到了.是否有一些属性需要应用于MSBuild任务的Execute函数来告诉它需要读取注册表?
编辑:
以下是从MSBuild任务执行的操作:
Return Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\MSSQLServer\Setup\", "SQLPath", Nothing)
Run Code Online (Sandbox Code Playgroud)
我相信这是由我的Vista x64机器上的注册表重定向器在32位运行MSBuild引起的.是否有任何方法可以告诉自定义MSBuild任务(用VB .Net编写),HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Setup\只有在没有任何内容的情况下查看然后查看HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\MSSQLServer\Setup\?
谢谢,
斯科特蓝
Pythonistas:
假设您要使用Pyparsing解析以下字符串:
'ABC_123_SPEED_X 123'
Run Code Online (Sandbox Code Playgroud)
分别ABC_123是一个标识符; SPEED_X是一个参数,123是一个值.我想到了以下使用Pyparsing的BNF:
Identifier = Word( alphanums + '_' )
Parameter = Keyword('SPEED_X') or Keyword('SPEED_Y') or Keyword('SPEED_Z')
Value = # assume I already have an expression valid for any value
Entry = Identifier + Literal('_') + Parameter + Value
tokens = Entry.parseString('ABC_123_SPEED_X 123')
#Error: pyparsing.ParseException: Expected "_" (at char 16), (line:1, col:17)
Run Code Online (Sandbox Code Playgroud)
如果我从中间删除下划线(并相应地调整Entry定义),它会正确解析.
如何使这个解析器变得有点懒惰,并等到它与关键字匹配(而不是将整个字符串作为标识符啜饮并等待_,而不存在.
谢谢.
[注意:这完全改写了我的问题; 我没有意识到真正的问题是什么]
我正在使用C#.NET页面中的以下代码生成JavaScript警报:
Response.Write("<script language=JavaScript> alert('Hi select a valid date'); </script>");
Run Code Online (Sandbox Code Playgroud)
它显示一个警告框,标题标题为"来自网页的消息".
是否可以修改标题?
我有一个Access 2000程序来处理公司的货物接收.我需要将库存物料和数量导出到Quickbook(企业2007?).我对Access程序有很好的处理,但对quickbooks一无所知.可以这样做吗?我需要什么呢?
当rsync打印出它为每个文件做的详细信息时(使用其中一个详细标志),它似乎包括已更新的文件和未更新的文件.例如,使用-v标志的输出片段如下所示:
rforms.php is uptodate
robots.txt is uptodate
sorry.html
thankyou.html is uptodate
Run Code Online (Sandbox Code Playgroud)
我只对更新的文件感兴趣.在上面的例子中sorry.html.它还会在输入目录名时打印出目录名,即使该目录中没有更新的文件也是如此.有没有办法过滤掉这个输出中没有更新文件的uptodate文件和目录?
c# ×2
c++ ×2
alert ×1
coding-style ×1
comments ×1
encryption ×1
grammar ×1
javascript ×1
msbuild ×1
msbuild-task ×1
parsing ×1
pyparsing ×1
python ×1
quickbooks ×1
r ×1
registry ×1
rsync ×1
s4 ×1
sockets ×1
tcp ×1
templates ×1
vtable ×1
xml ×1