c********e 发帖数: 383 | 1 solution 1, include your template definition in your header file.
solution 1 upgrade, pre compile that header
solution 2, explicit instantiation in a.cpp |
|
l***g 发帖数: 1035 | 2 you don't need to write a rule for header files.
#include can be treated as literally. If a header file changes, source will
be recompiled though the source itself doesn't have a different time stamp.
it's compiler's job, you don't need to do it. |
|
K*****n 发帖数: 65 | 3 Here is a quote from http://www.cprogramming.com/tutorial/statickeyword.html
An important detail to keep in mind when debugging or implementing a program
using a static class member is that you cannot initialize the static class
member inside of the class. In fact, if you decide to put your code in a
header file, you cannot even initialize the static variable inside of the
header file; do it in a .cpp file instead. Moreover, you are required to
initialize the static class member or it will not b |
|
p*******n 发帖数: 273 | 4 I want to read data from files, and the format of data is below:
struct sac
{ struct header hdr;
float * data;
} sacbin;
I try fread(&sacbin.hdr,sizeof(struct header),1,fp), but it does not work.
I don't know why. Thank you! |
|
n*w 发帖数: 3393 | 5 skip header 去掉 header都很容易吧? |
|
|
s******n 发帖数: 34 | 7 用WSARecv但是事先不知道接受多少数据
每个数据包都有一个header,里面包含接下来数据大小。
那在接受方, 是不是要调用两次WSARecv? 第一次接受header大小,
这个接受完成后, 再投递一个WSARecv, 接受数据?
像我所说的那样可以吗?两次WSARecv是不是效率低了?
还是说用recv先peek下,再用一次WSARecv?
谢谢! |
|
t****t 发帖数: 6806 | 8 C语言本来就不能这么写...
C++的话, VC6过时了, 换一个
google一下有一些别的方案
A. If you don't want to switch compilers, an alternative is this macro.
Place
it at the beginning of each file.
#define for if (0); else for
我不确定这样可以work.
B. VC++ 6 has an option (/Za) that enforces the correct scope for
variables defined in the header of a for loop (etc.) The problem is
that when you turn this switch on, it enforces a number of other
rules, and its standard headers (among other things) won't compile
when those rules are enforced |
|
b***y 发帖数: 2799 | 9 ☆─────────────────────────────────────☆
jyu (jyu) 于 (Fri Mar 14 16:55:32 2008) 提到:
hi All,
I have a problem casting a 4 byte unsigned char into integer.
here is my code:
this is C++ code:
// header is just a structure with a field of 4 byte unsigned char
unsigned int sequence = *(reinterpret_cast(header->m_sequenceNum
));
and the sequence is always some overflow #!
all comments/help are appreciated!
Thank you very much!
☆─────────────────────────────────────☆
Xentar (思考猪) 于 |
|
h**o 发帖数: 548 | 10 我是要编一段程序(shell or perl) 看snoop里有无我要的字符串. 不是用眼睛看. 所
以winshark 和
ethereal 都不适和我.
假设我的snoop 结果 是 a.snoop,前文说的snoop.txt是我用
snoop -i a.snoop -x0 > snoop.txt 得到的. 但snoop.txt中可读的文本在最右列, 我
还得某种方
式把可读的文本取出来再search我要的字符串. 麻烦.
我现在想了一个别的办法:
snoop -i a.snoop -v > a1.txt, 这样我可以从a1.txt里得到packet headers 信悉了(而
我要找的字符串 就应在http header 里).如:
TCP: No options
TCP:
HTTP: ----- HyperText Transfer Protocol -----
HTTP:
HTTP: GET /beast_uns/index.php HTTP/1.0
HTTP: User-Agent: Wget/1.11.1 (Red Hat modified)
HTTP: Accept: |
|
X****r 发帖数: 3557 | 11 Your overloaded 'new' must be declared in every translation unit
of your program. In other words, every .cpp file need to include
the header which has the declaration directly or indirectly.
This is just like any other function you overload -- if the compiler
doesn't see your declaration, it won't know to use your overloaded
function.
the
header,
has |
|
g*********s 发帖数: 1782 | 12 more confused now.
so inline keyword is a message from the coder to the compiler about two
things: 1) code expansion, which is a suggestion. the compiler can
either honor it or not; 2) external linkage, which is a requirement.
otherwise odr is violated.
but if the compiler doesn't honor 1), how could it meet 2)?
the following article says inline functions by default have external
linkage. is it possible to use another type of linkage? how?
http://stackoverflow.com/questions/4193639/inline-functi... 阅读全帖 |
|
j*******n 发帖数: 3254 | 13 设计了一个小Script将访问我网站首页的人的IP传回我的邮箱。但非常奇怪的事情发生了,每次我进入首页,邮箱中总会同时收到了两个邮件,收到时间是一样的,其中一个邮件总是显示是我本机的外部IP地址,另一个邮件显示其他不同的IP地址。
我在ip2location上查了其中两个地址,一个地址来自于加州(是我机器上安装的杀毒软件公司的地址),另一个来自于日本Tokyo (好象是什么 japan network
information centre)。
请问这是怎么回事,是我的Script设计的有问题吗?
Script的内容和安装过程如下:
自己做了一个网站,在一个ISP那申请了主页空间。在网站home page 上加了如下一句话
在这个www.aaa.net上 上载了index2.php like this one.
$IP = $_SERVER['REMOTE_ADDR'];
$to = "a*[email protected]"; $emai... 阅读全帖 |
|
i*****o 发帖数: 1714 | 14 找个可以看http header的工具看看成功的那个header,最有可能是referer,但也有可
能是hidden input, 看看就知道了。 |
|
r*******y 发帖数: 1081 | 15 //1.cpp
#include
// using namespace std;
int main(){cout<<1;}
this file can not be compiled since cout is not declared in this scope.
I read the header file iostream and find a declare for cout:
extern ostream cout;
It seems cout is declared in the header file iostream, but
why we also need to write down
using namespace std; ?
thanks. |
|
t****t 发帖数: 6806 | 16 18.4 Dynamic memory management [lib.support.dynamic]
1 The header defines several functions that manage the allocation of
dynamic storage in a program.
It also defines components for reporting storage management errors.
Header synopsis
namespace std {
class bad_alloc;
struct nothrow_t {};
extern const nothrow_t nothrow;
typedef void (*new_handler)();
new_handler set_new_handler(new_handler new_p) throw();
}
void* operator new(std::size_t size) throw(std::bad_alloc);
void* operator ne... 阅读全帖 |
|
b******n 发帖数: 1629 | 17 第一个请求是正常的,第二个请就啥都没有了。连header都没有,你是说第一个请求的
header么,是
HTTP/1.1 200 OK
Date: Sat, 07 Jan 2012 01:56:12 GMT
Server: Apache/2.2.14 (Ubuntu)
Last-Modified: Thu, 08 Dec 2011 17:40:14 GMT
ETag: "103cd6-a253d9-4b398293a485c"
Accept-Ranges: bytes
Content-Length: 10638297
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: audio/mpeg |
|
b******n 发帖数: 1629 | 18 第一个请求是正常的,第二个请就啥都没有了。连header都没有,你是说第一个请求的
header么,是
HTTP/1.1 200 OK
Date: Sat, 07 Jan 2012 01:56:12 GMT
Server: Apache/2.2.14 (Ubuntu)
Last-Modified: Thu, 08 Dec 2011 17:40:14 GMT
ETag: "103cd6-a253d9-4b398293a485c"
Accept-Ranges: bytes
Content-Length: 10638297
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: audio/mpeg |
|
f******y 发帖数: 2971 | 19 I think both will work. A very good convention is to use <> for system
headers, and "" for your own headers. |
|
d****p 发帖数: 685 | 20 C/C++, as a static language, compiles translation units separately and
header files make sure different object files talk with each other via
correct calling conventions.
Until the C/C++ compilation model changes, header files will be always there.
And your comparison between "other languages" and C/C++ doesn't make much
sense since so called "other languages" are usually based on C/C++
components. |
|
b**********8 发帖数: 239 | 21 多谢高人指点.The updated script works fine under Python 2.7. But it will
still fail if runing it under Python 3.2 after converting. (I guess it
might be related to different handling for header info of request in 3.2.
But I am not sure). Is there anything wrong with following script ?
多谢了!
Code :
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import urllib.request, urllib.parse, urllib.error, urllib.request, urllib.
error, urllib.parse, http.cookiejar
#from bs4 import *
username = 'id'
password = ... 阅读全帖 |
|
r*********r 发帖数: 3195 | 22 interface 的抽象度更高。implementation 是实现的细节。
从实用上讲,header file 是为了便于compiler 作 type checking.
因为编译过的 binary 里不含type information.
java 的 bytecode 里则存有 type meta data,
所以不用单独的header file |
|
a**********e 发帖数: 157 | 23
原因大概2个
1. 如果implementation也放在header file里,同时很多其他文件都要include这个文
件,会导致严重redundancy,同样的代码出现很多次。(在cpp preprocess后)
2. 如果在cpp文件改变implementation,而declaration(header file里)不变,只需
要recompile cpp file。否则,所有include这个文件的所有file都要recompile,很浪
费资源和时间。 |
|
|
w*s 发帖数: 7227 | 25 检测高手的时候到了
how to convert my c code into python ?
struct Header{
int f1;
int f2;
};
struct Data{
long f3;
unsigned short f4;
...
};
struct Info{
struct Header myHeader;
struct Data mhData;
};
struct Info myInfo;
// initialization here
myFunc(&myInfo, 1, 2, 3); |
|
r****t 发帖数: 10904 | 26 Header = [('f1', 'i4'),('f2', 'i4')]
Data = [('f3', 'i8'),('f4','u4'),...]
Info = [('myHeader',Header), ('mhData',Data)]
myinfo = np.array(((0,0), (0,0)), dtype=Info)
myfunc(myinfo, 1, 2, 3)
另 in python don't use camel case name for variables and functions, that's
quite ugly. |
|
s***o 发帖数: 2191 | 27 In HTTP/1.1, persistent connection is the default behavior. You need to add
a "Connection: Close" header to close it explicitly.
If the protocol is HTTP/1.0, then you have to add "Connection: Keep-Alive"
to each message. The connection will be closed if the receiver does not see
this header. |
|
g*****g 发帖数: 34805 | 28 没看出来,你给讲讲?
Dummy database constrained benchmarks favors 3x vert.x over Node.js.
As for 'requests per second' it's 3.5x faster (7x using both processor cores
, but this is unfair).
Vert.x sent more data down the tubes, I suppose it's caused by different '
Date' header formatting (it uses Rhino's NativeDate instead of JavaScript's
Date) . It also prints slightly longer 'X-Response-Timeout' (e.g. 13.0
instead of 13). I might look into it in the future. I tried to even out
basic benchmarks by adding... 阅读全帖 |
|
m********5 发帖数: 17667 | 29 我已经造过了, 用c++不难
但矩阵运算还是得用库,人家的效率已经做得很好了, 自己造轮子不划算. 问题只是
matrix header兼容性问题.
现有的图像处理库,只有简单的矩阵运算,稍微不常用一点就得转格式, 比如openCV必须
以pixel为单元, 如果要单独提出某个channel做运算,得先内存拷贝
所以我写了自己的matrix header, 让所有库可以用同一个matrix实现一些功能
GC要小心, 每个库有自己独立的一套方法, 有时候挺麻烦的, 只能自己管理
库 |
|
c*********e 发帖数: 16335 | 30 做模块,可以把一个模块放到一个php文件里,用的时候,在需要的地方用require_
once就行了。
比如header.php是header模块,footer.php是footer模块。每个网页都把这2模块加上
去。 |
|
c******3 发帖数: 296 | 31
same
呢(
keep alive在Apache2.0是缺省的。
你也可以看看你客户端API是不是让你定义http header的属性。property name=
connection, value=true. 查一下Request class是怎么加http header map的。
client
应该是每个browser里面有个connection pool.所有的tab共用这个pool。identify很简
单。你在你的browser里打开10个tab。每个都去下载长文件(video or movie)。你会
发现你文件夹里可能只有6个正在下载的文件。这说明你只能同时并行6个connection。
其余的要等。browser可能会让你配制同时connection的数目。 |
|
v*******e 发帖数: 11604 | 32 this is very easy,
header=["v1","v2","V3"]
a=[1,2,3]
File=open("whateverplace/whateverfile.csv",'w')
File.write(",".join(header)+"\n")
File.write(",".join([str(item) for item in a])+"\n")
File.close() |
|
z****e 发帖数: 54598 | 33 http://www.techempower.com/blog/2014/03/04/one-million-http-rps
关键字undertow
As we and our collaborators prepare Round 9 of our Framework Benchmarks
project, we had an epiphany:
With high-performance software, a single modern server processes over 1
million HTTP requests per second.
Five months ago, Google talked about load-balancing to achieve 1 million
requests per second. We understand their excitement is about the performance
of their load balancer1. Part of what we do is performance consulti... 阅读全帖 |
|
h**********c 发帖数: 4120 | 34 我老当年用qt/c++写东西玩,发现模板只能放在header file
几千行一个文件,自己都不想看第二遍
在座高人都写过几千行的模板header,还是有另招高
另外想起来,c/c++ 的final是const,hihi |
|
k**n 发帖数: 3989 | 35 放狗 cors, 在server 端response header 里设.
Node.js 的Express
res.header('Access-Control-Allow-Origin', '*'); |
|
c*********e 发帖数: 16335 | 36 php 没有linq, 对unicode的支持跟不上时代, multi-threading最近才有实现,
restful web services也是java,c#,php中最晚才实现的。更别说它的网站的rps比java
,c#的低。header的使用非常不方便,前面一定要没有输出,才能用header. 很多的小
功能,都没有c#,java的系统全面。做小项目还可以。做大项目的,有几个用的php,除
了facebook? |
|
o*********r 发帖数: 203 | 37 Add header to call (i.e. in jQuery):
$.ajax({url : ,
type : 'get',
contentType : 'application/json',
dataType : 'json',
cache : false,
headers : {'Authorization' : "Basic cmVtb3RlMTpyZW1vdGUx"}};
'cmVtb3RlMTpyZW1vdGUx' is a base64-encoded string. The plain text is <
username>: |
|
f*********t 发帖数: 17 | 38 Right. This is http standard header.
If using oauth the header becomes Authorization: Bearer {access_token} |
|
t**********s 发帖数: 930 | 39 if [item for item in httpobj.headers.keys() if "content-type" in item]:
return httpobj.headers['content-type']
被这个嵌套的if 搞糊涂了。 |
|
t**********s 发帖数: 930 | 40 能说的更清楚些吗?
原来的Code 是这样的:
if "content-type" in httpobj.headers.keys():
return httpobj.headers['content-type']
不知啥原因改成现在这样了 。 |
|
n*****t 发帖数: 22014 | 41 https://docs.angularjs.org/api/ng/service/$http
The response object has these properties:
data – {string|Object} – The response body transformed with the transform
functions.
status – {number} – HTTP status code of the response.
headers – {function([headerName])} – Header getter function.
config – {Object} – The configuration object that was used to generate the
request.
statusText – {string} – HTTP status text of the response.
A response status code between 200 and 299 is considered a success s... 阅读全帖 |
|
c********1 发帖数: 5269 | 42 String or object,根据 header 来的吧 -- I does not define header.
customer.html source
{{ x.Name + ', ' + x.Country }}
|
|