由买买提看人间百态

topics

全部话题 - 话题: msvc
1 2 下页 末页 (共2页)
x**n
发帖数: 1055
1
的确是传的指针,但是没有用semaphore, boost thread好像没有这个东西吧
是这样的,假设有msvc.dll和mingw.dll
又用VC8.0写了个主程序
typedef struct
{
boost::barrier* brr;
boost::mutex* mtx;
boost::condition* cv;
} BT_PARAM;
main()
{
...
BT_PARAM* bt_param;
bt_param=new BT_PARAM;
接下来初始化bt_param;
接下来loadlibrary,打开msvc.dll和mingw.dll
产生两个线程
boost::thread* t_msvc=new boost::thread(p_msvc,bt_param);
boost::thread* t_mingw=new boost::thread(p_mingw,bt_param);
...
}
然后在msvc.dll.cpp中加上这么一段:
...
bt_param->brr->wait();
...
同样在在mingw.dll.cpp中加上这么一段:
..... 阅读全帖
h**********c
发帖数: 4120
2
I review the post.
It seems you probably can't do this, cause the underling thread library for
MingW/cygwin etc is pthread. MSVC uses thread library Microsoft wrote.
So in your Ming code and MSVC, do they include the same boost library.
i*****f
发帖数: 578
3
来自主题: Programming版 - sscanf problem in MSVC 7
All right, you guys are right. I found it's printed like 0.8000...4 in gdb
the same phenomena as in MSVC. But when I compare it with 0.8, it returns
true.
x**n
发帖数: 1055
4
我用MSVC的LoadLibrary和GetProcAddress可以打开另一个MingW的DLL并且调用MingW
DLL的函数没问题,但是要同步就不行,呵呵
x**n
发帖数: 1055
5
谢谢,好像有点明白您说的思路,不过是否能稍微详细展开一下实现的细节?
就是在mingw.dll.c和msvc.dll.c中把GetProcAddress得到的
ptr_func_mingw和ptr_func_msvc作为参数传入用其中一个编译器写的wait()?然后在
wait中实现所有的同步操作?
我是不是应该有wait(ptr_func_mingw)和wait(ptr_func_msvc)这样一个函数?
有没有这方面成功的例子?
非常感谢!!
b***i
发帖数: 3043
6
我建议你做个试验,写两个简单的dll,一个用mingW, 一个msvc, 在里面做循环,等待
,同步。主程序开始两个线程后要等待join吧。
如果出错,用下面的方案再试试。在dll中都定义startThread(.......,
aFunctionPointertoWait)
然后在主程序中定义一个函数,用来wait,你那个boost的barrier也在主程序中声明,
通过这个函数来等待。就是说,这个barrier的等待不是分别在两个dll中,而是统一通
过主程序的唯一的函数来做,避免不同编译器不同的实现不兼容。wait那个函数,可以
增加一些参数,你可以打印看看谁呼叫你,那一行,要增加很多调试信息。
x**n
发帖数: 1055
7
我已经实现此mingw和msvc线程同步的功能,都用的boost.thread,现在在win和linux
上都可以编译运行,非常感谢bihai的提示

for
k**********g
发帖数: 989
8
来自主题: Programming版 - C问题,被64bit iPhone搞晕了

是被 MSVC 搞昏吧。除了 MSVC 有这样规定(为了 MS 自家代码的向後兼容),没听过
其他编译器有这样的保证。
w*x
发帖数: 518
9
来自主题: Programming版 - python转化成exe的能力怎样?
不会呀,我用mingw-w64有一阵子了…
而且msvc也可以呀,除了openmp支持以外别的都是免费的
而且以后(py3.5)用msvc的时候openmp也免费了
S**I
发帖数: 15689
10
Both MSVC and GCC provide hash_map and C++0x has unordered_map.
m****s
发帖数: 395
11
Robert Half IT SEARCH is seeking to fill the position of C++ Software
Development team leader. This production-oriented engineering position
includes designing, implementing, and extending a backbone framework for
advanced security applications by integrating various technologies such as:
Web and mobile GUI applications
Video capture, analysis, archiving, and streaming (video
manipulation)
IP-based sensors and output devices
Custom drivers, thi... 阅读全帖
a****a
发帖数: 5763
12
因势而动
1981年, Jean-Marie Hullot拿到巴黎第十一大学的计算机科学博士资格后,开始了法
国国家信息与自动化研究所(INRIA)的研究生活。
Jean-Marie Hullot的名字似乎不为大众所熟知,但他设计的Interface Builder 却深
入人心,创造了一个个软件神话。
20世纪70年代初,正是面向对象程序设计开始走上历史舞台的时期。许多现代计算机技
术的诞生地Xerox PARC(施乐帕洛阿尔托研究中心)的Alan Kay、Dan Ingalls、Ted
Kaehler 、Adele Goldberg等人,从1969年开始研发一款面向对象的程序语言
Smalltalk,并于1980年正式公布。这是一个完整地实现面向对象范型的编程套件,包
含了一种面向对象的程序设计语言、一种程序设计库和一个应用开发环境(ADE)。
虽然当时的机器跑得巨慢无比,但Smalltalk先进的思想对其他众多的程序设计语言(
Objective-C、Actor、Java和 Ruby)的产生起到了极大的推动作用,对计算机工业界
的发展产生了非常深远的影响。我们将会在今后介绍Obj... 阅读全帖
a****a
发帖数: 5763
13
2011年12月3日,LLVM 3.0正式版发布,完整支持所有ISO C++标准和大部分C++ 0x的新
特性, 这对于一个短短几年的全新项目来说非常不易。
开发者的惊愕
在2011年WWDC(苹果全球开发者大会)的一场与Objective-C相关的讲座上,开发者的
人生观被颠覆了。
作为一个开发者,管理好自己程序所使用的内存是天经地义的事,好比人们在溜狗时必
须清理狗的排泄物一样(美国随处可见“Clean up after your dogs”的标志)。在本
科阶段上C语言的课程时,教授们会向学生反复强调:如果使用malloc函数申请了一块
内存,使用完后必须再使用free函数把申请的内存还给系统——如果不还,会造成“内
存泄漏”的结果。这对于Hello World可能还不算严重,但对于庞大的程序或是长时间
运行的服务器程序,泄内存是致命的。如果没记住,自己还清理了两次,造成的结果则
严重得多——直接导致程序崩溃。
Objective-C有类似malloc/free的对子,叫alloc/dealloc,这种原始的方式如同管理C
内存一样困难。所以Objective-C中的内存管理又增... 阅读全帖
m********d
发帖数: 27
14
来自主题: Java版 - 如何在WINDOWS上DEBUG JAVA
don't use gui that often except msvc, maybe just get used to vim
m******t
发帖数: 2416
15
来自主题: Java版 - JavaBean variable name standard
Well if all of them start with m_, at least they are consistent. 8-)
m_* originated from MSVC practice, I think.
For a couple of years I had all of my instance variables starting
with _, which actually makes the code much more readable if
you have to read the code in an editor without syntax highlight.
H**********k
发帖数: 224
16
似乎有编译器的问题
matlab win是msvc 2k5编译的
linux下面是gcc编译的
但是,matlab核心就是intel mkl啊,难不成
intel mkl本身在lin/win下面performance就差很多?
j****j
发帖数: 270
17
8. What’s potentially wrong with the following code?
long value;
//some stuff
value &= 0xFFFF;
Note: Hint to the candidate about the base platform they’re
developing for. If the person still doesn’t find anything wrong with the
code, they are not experienced with C++.
9. What does the following code do and why would anyone write something
like that?
void send (int *to, int * from, int count)
{
int n = (count + 7) / 8;
t****t
发帖数: 6806
18
有人自宫,再问一遍
also, you didn't answer me, WHY you claim MSVC reports error when you call
with an rvalue. what kind of rvalue did you used to call foo(int) and foo(
int&)? can you tell me?
X***X
发帖数: 302
19
我下了一个msvc,好大啊,c盘都挤爆了
dev-c比较小么?
c*******h
发帖数: 527
20
来自主题: Programming版 - Qt/Windows 开源版本将支持 VS Express
http://cavendishqi.blogspot.com/2007/09/qtwindows-vs-express.html
Qt/Windows 开源版本将支持 VS Express
Trolltech 将会在 Qt/Windows 开源版本中支持 Visual Studio Express,其中包括对
于 MSVC Makefile 和项目的生成器,但不包括 VS Integration。
这个支持应该会在 Qt 4.4 和 Qt 4.3.2 中出现。
Girish Ramakrishnan: Qt/Windows Open Source Edition to support VS Express
http://labs.trolltech.com/blogs/2007/09/18/qtwindows-open-source-edition-to-support-vs-express/
经测试最新 Qt 4.3.2 和 Qt 4.4 的快照都已经支持这个特性。
v*****x
发帖数: 8
21
来自主题: Programming版 - C array
A small mistake above.
It's apparent that your version of MSVC does not support scenario 2. However
, for scenario 1, you may need to change the code to:
const int nn = 255;
such that it compiles.
i*****f
发帖数: 578
22
来自主题: Programming版 - sscanf problem in MSVC 7
Hi, I'm having trouble with the following codes;
=======================================
sscanf(s, "%d %s %s %lf %lf %lf %d",
&(intsec[i].ref),
intsec[i].name,
intsec[i].state,
&(intsec[i].dis),
&(intsec[i].logi),
&(intsec[i].latt),
&(intsec[i].pop) );
======================================
When the string s is like "342 omak WA 0.8 119.5141 ...."
The 4th value intsec[i].dis will scan in 0.799999999...
k****e
发帖数: 100
23
来自主题: Programming版 - sscanf problem in MSVC 7
It seems right.
0.7999999..... == 0.8
i*****f
发帖数: 578
24
来自主题: Programming版 - sscanf problem in MSVC 7
But why is that when I try that using gcc, I got exactly 0.8 ???
m****e
发帖数: 7
25
来自主题: Programming版 - sscanf problem in MSVC 7
How do you know it's exactly 0.8 on gcc?? There is never an "exact 0.8" for
floating point value. 0.8 = 4/5, and 5 is not a power of 2.
t****t
发帖数: 6806
26
来自主题: Programming版 - sscanf problem in MSVC 7
没听说过直接比较两个浮点数相等的
d*******d
发帖数: 2050
27
来自主题: Programming版 - sscanf problem in MSVC 7
normal,负点精度。
P********e
发帖数: 2610
28
来自主题: Programming版 - 一道c++的考古题
ok, anyhow, gcc does not mean more c++ standard, nor MSVC
I'll stick with my temp obj
t****t
发帖数: 6806
29
来自主题: Programming版 - 一道c++的考古题
Usually, g++ DOES mean more c++ standard. At least more c++ standard than
MSVC. Although g++'s performance is not as good.
c***d
发帖数: 996
30
☆─────────────────────────────────────☆
jjwwjj (jjwwjj) 于 (Sun Nov 5 00:25:40 2006) 提到:
8. What’s potentially wrong with the following code?
long value;
//some stuff
value &= 0xFFFF;
Note: Hint to the candidate about the base platform they’re
developing for. If the person still doesn’t find anything wrong with the
code, they are not experienced with C++.
9. What does the following code do and why would anyone write something
like that?
vo
y****e
发帖数: 23939
31
来自主题: Programming版 - Help: Another C++ compilation error on GCC
Thank you very much, thrust!
That IS the problem. This code is ported from MSVC. They define a macro
round(). I remove it and use the function round() available, then the
problem gone.

).
y****e
发帖数: 23939
32
来自主题: Programming版 - C++ help: 一个multiple definition problem.
一个从MSVC port到GCC的project, 有一个GlobalDefinition.h在一个目录中,定义了
很多global的变量,现在编译的时候出现了很多"multiple definition of blah blah"
的错误在link stage。这个头文件已经有inclusion guard,怎么还会有这个问题呢?
网上查了一下,说这个inclusion guard只能protect a single translation unit。有
点迷惑,怎么解决这个问题呢?
Thx
s*****g
发帖数: 323
33
来自主题: Programming版 - spent a lot of time try to compile boost
It simply doesn't work.
What is the reason?
I was trying to use the thread library. And it seems that this library need
to be compiled. Since I am not using Visual Studio, I need to do it by
myself. tried to compile with bjam and boost.build, it simply doesn't work.
It says " msvc.jam:263: in configure-really *** argument-error * rule path.
make(native) * called with:() *missing argument native
anybody can help me?
p***o
发帖数: 1252
34
来自主题: Programming版 - 这个warning什么原因
Herb Sutter不喜欢那个throw,所以MSVC里会忽略这个东西。
具体看
Exceptional C++ Style by Herb Sutter
Item 13: A Pragmatic Look at Exception Specifications

^^^^^
k****f
发帖数: 3794
35
来自主题: Programming版 - Turbo C 2.0 问世20年了
tc2是非常经典的
用过一学期的,后来就到msvc上去
f**y
发帖数: 138
36
Not so easy. Programs written with MFC are usually not compatible with
MatLab's graphics library. Such programs will crash at run time if linked
with dll built with MatLab's compiler.
I only succeeded once with MatLab's old 2.x compiler which compiled m files
into tons of C or C++ files. Then made a wrapper around those C or C++ files
to provide an interface without referring to MatLab's mwArray class. Those
files were compiled into a dll with MSVC. The original MFC program linked
with this dll
X****r
发帖数: 3557
37
来自主题: Programming版 - C++ question
I think boost and gcc/MSVC are correct. From the C++ standard draft:
9.5 unions [class.union]
2 A union of the form
union { member-specification } ;
is called an anonymous union; it defines an unnamed object of unnamed
type. The member-specification of an anonymous union shall only
define non-static data members. [Note: nested types and functions
cannot be declared within an anonymous union. ] The names of the mem-
bers of an anonymous union shall be distinct fr
x****u
发帖数: 44466
38
这个仅仅在gcc的非线程安全的优化模式下才有意义。
现在几乎没有这样的程序非要单线程的极端优化,MSVC也是默认不破坏多线程语义。
x****u
发帖数: 44466
39
我手头没有gcc的环境,msvc的行为和我预测一致。
另外我能查到的所有文档都没有说global variable仅仅在单线程时是global的,质疑
标准的其实是你。

you
h****g
发帖数: 71
40
No this problem on G++4.4. I guess it may appear on MSVC.
struct A
{
virtual void f1(){};
virtual void f2(){};
virtual void f3(){};
virtual void f4(){};
virtual void f5(){};
virtual void f6(){};
virtual void f7(){};
virtual void f8(){};
virtual void f9(){};
virtual void f10(){};
virtual void f11(){};
virtual void f12(){};
virtual void f13(){};
virtual void f14(){};
virtual void f15(){};
virtual void f16(){};
virtual void f17(){}
c**r
发帖数: 108
41
MSVC 10.0 is fine with this.
d****p
发帖数: 685
42
来自主题: Programming版 - #ifdef _MSC_VER 是什么意思啊?
CString is ATL stuff so it is only for MSVC platform.
If you want cross-platform code, change it to std::string
s********z
发帖数: 5411
43
我有一个从CCD camera采集图像的小程序,以前是用MSVC,没什么问题,现
在为了把界面变得漂亮点改成Qt+mingw的。
在用library的时候出现了undefined reference to "func" 的错误,
用的是national instrument的library, niimaq.h.
不知道该怎么办,大家请帮帮忙。
多谢
e****d
发帖数: 895
44
来自主题: Programming版 - How to use volatile in c++?
It depends on compilers. MSVC does give volatile variables
acquire/release semantics. GCC might also do. But c++0x
will introduce atomic variables to replace this usage.
a*******e
发帖数: 428
45
Thanks for your reply. I think .dll can be used without license.
But what I was confusting was .lib files, such as MSVC.lib generated by
microsoft, to be used in linking. In this case, the objective code will be
incorporated into your excutables, but you don't include their source code
in your source code. Will excutables generated by this method be covered by
the license?
My understanding of the terms is 'yes', though you don't need to publish
your source code but you have to include a copy of ... 阅读全帖
l*********s
发帖数: 5409
46
来自主题: Programming版 - please help debug this code
MSVC老是抱怨没有《右边是TEntry类型的重载,但是明明一开始就重载了啊,到底怎么
回事请大家看看。
(这段代码来自于Think in C++)
#include
#include
#include
#include
#include
#include
#include
using namespace std;
typedef map> Thesaurus;
typedef pair> TEntry;
typedef Thesaurus::iterator TIter;
ostream& operator<<(ostream& os, const TEntry& t){
os << t.first <<": ";
ostream_iterator out_it(os," ");
copy(t.second.begin(),... 阅读全帖
t****t
发帖数: 6806
47
actually i think by default cl doesn't optimize either.
and my impression (4-5 years ago) gcc code IS slower than msvc.
x**n
发帖数: 1055
48
我有两个windows下的DLL,
一个是Code::blocks加上MingW 4.3.3 编译的DLL
另一个是Visual C++ 2005编译的DLL
都是差分程序,因此想通过类似boost.thread的实现线程同步并且传递数据
因为是不同编译器生成的DLL,所以想问问有没有这个可能实现这两个不同编译器生成
的DLL线程的同步?
因为两个DLL都依赖很多库,所以想要都用同一个编译器去编译(比如都用Visual C++或
者都用MingW编译成功)太困难了
谢谢!
1 2 下页 末页 (共2页)