Yochai Timmer

1

votes
1

answer
1.8k

views

OCL - iterate for each item

I have a class A with a collection of other classes (B). How do I represent in OCL that for each class (B) in the collection there's a constraint on a field ? I thought something like: A.collection->iterate().field = SomeConstraint
Yochai Timmer
1

votes
1

answer
192

views

C++/CLI umanaged pointer in constructor

I want to make a C++/CLI wrapper of some C++ class. The problem is that I want the ref class to be initiated with a reference of the c++ object: A (A& a); This works fine as long as it is in the same aseembly and used in the same project. But when I try to reference that project from a different pro...
Yochai Timmer
1

votes
1

answer
52

views

How to check which projects are dependent on a .cpp file?

I've got a solution with many projects that are dependent on one another (large program, about ~200 projects). Alot of these connect are compiled as static libs, and are compiled into other projects that use link time code generation. Now, lets say i want to test something and change a single .cpp f...
Yochai Timmer
1

votes
2

answer
569

views

Install SQL server 2008 R2 with VS 2010

Ok, I've installed SQL Server 2008 R2. I'm trying to add a 'SQL Server Database' to an ASP MVC project. But it keeps telling me I need SQL Server for it to work. What do I need to do to setup the SQL Server properly for it to work with VS2010 ? I've tried messing with the SQL Server Management Studi...
Yochai Timmer
1

votes
1

answer
493

views

Getting dynamic atexit destructor link error with custom toolset - eh vector destructor

I'm getting a weird linker error when trying to compile against a VS2005 CRT with a Visual Studio 2015 toolset. The same code compiles perfect on any other toolset version (2005,2010,2012,2013). The code must compile under VS2005 CRT to properly link with other projects. How to reproduce: Create a...
Yochai Timmer
1

votes
1

answer
199

views

Keep the delegate argument names when compiling C++/CLI for .Net

In C# I can get Visual Studio to keep the delegate's argument names. For example if I have: public delegate void Blah(object myArg); public event Blah Foo; Then when I add a method to the event, Visual Studio UI automatically keeps the names and creates the method: void Form1_Foo(object myArg); Bu...
Yochai Timmer
16

votes
14

answer
47.4k

views

IntelliJ IDEA - Android JDK doesn't work

I've just installed IntelliJ IDEA 10.0.0.2 Community edition I've installed Android SDK ... (C:\Program Files\Android\android-sdk-windows) I want to make a new android project, so I a create a new project, select Android Module, next , next... Then when i need to choose the JDK, I go to the androi...
Yochai Timmer
17

votes
4

answer
2.2k

views

Is pointer dereferencing atomic?

Lets say I have a pointer to an integer. volatile int* commonPointer = new int(); And I have multiple threads that dereference that pointer. int blah = *commonPointer; But, one thread needs to change that pointer's address: int* temp = new int(); int* old = commonPointer; InterlockedExchange(&comm...
Yochai Timmer
17

votes
4

answer
2.8k

views

C# Compiler optimization - Unused methods

Does C# compiler (in VS2008 or VS2010) remove unused methods while compiling ? I assume that it may have a problem deciding if public methods will ever be used, so I guess it will compile all the public methods. But what about private methods that are never used inside a class ? EDIT: Are there a se...
Yochai Timmer
18

votes
3

answer
6.8k

views

Generics can't infer second parameter? [duplicate]

This question already has an answer here: Why must I provide explicitly generic parameter types While the compiler should infer the type? 3 answers I've noticed that the C# compiler doesn't infer second generic parameter. Example: C++ template code: (yea I know that templates don't work like generi...
Yochai Timmer
19

votes
3

answer
6.1k

views

C# checked block

Can someone explain to me what exactly is the checked an unchecked block ? And when should I use each ?
Yochai Timmer
21

votes
4

answer
15.5k

views

Visual studio designer in x64 doesn't work

In Visual Studio 2010 64bit I can't design my forms. I keep getting this warning (and error): Warning 18 The designer could not be shown for this file because none of the classes within it can be designed. The designer inspected the following classes in the file: MainForm --- The base class 'Bla...
Yochai Timmer
6

votes
3

answer
2.2k

views

What does “this” mean in a static method declaration?

I've seen some code that uses the keyword this in the function parameter declaration. For example: public static Object SomeMethod( this Object blah, bool blahblah) What does the word this mean in that context?
Yochai Timmer
11

votes
5

answer
38.9k

views

How can i convert a date in php to SQL format ? (and insert it)

I'm trying to insert a date , lets say CURDATE() to an sql DateTime field. My date is in the format of: 28/01/2008 When I try to insert it to the SQL, I get just zeroes. So how can I convert it properly?
Yochai Timmer
2

votes
0

answer
143

views

Can I use existing shared memory with boost::interprocess::managed_shared_memory?

I have shared memory block created in another module. This wasn't created via boost (that module is written in C). Can i somehow envelop that shared memory block with a boost::interprocess::managed_shared_memory ? I'd really like to reduce handling complexity by wrapping it up neatly with a manag...
Yochai Timmer
2

votes
3

answer
6.8k

views

How can i cast a struct to a char[] array?

I have a variable of type Blah. I want to cast it to char[sizeof(blah)], without copying. I need the type cast to be strong enough to instantiate a template that expects char[N]. I've tried many things, but i can't quite get it. I want something like this to work correctly: class Blah { int a; };...
Yochai Timmer
2

votes
3

answer
1.1k

views

Get object call hierarchy

Lets say I have 3 classes: class A { void do_A() { //Check object call hierarchy } } class B { void do_B() { A a; a.do_A(); } } class C { void do_C() { B b; b.do_A(); } } And then I call: C c; c.do_C(); How can i get the object call hierarchy from within A's do_A() ? I mean I want to get the refer...
Yochai Timmer
3

votes
4

answer
1.8k

views

How can i get a permutation given indexes?

I've got a list of objects: array = [object0,object1,object2,object3,object4] and i want to change the order of the items given a permutation: permutation = [ 2 , 4 , 0 , 1 , 3 ] Is there a command in python that will do something like: result = Permute(array,permutation) result = [object2,object4,o...
Yochai Timmer
3

votes
3

answer
172

views

How to check user choice algorithm

I have an algorithm that chooses a list of items that should fit the user's likings. I'll skip the algorithm's details because of confidentiality issues... Now, I'm trying to think of a way to check it statistically, with a group of people. The way I'm checking it now is: Algorithm gets best results...
Yochai Timmer
2

votes
2

answer
285

views

SEHException while in paint() - .NET handling is ruining call stack

I have error handling code that is designed to catch unnhandled exceptions, and then create a dump. Now, i've encountered a few situations where this doesn't work well in the transition between Native and managed code. For example if in a Paint() event I call some native code, and that native code...
Yochai Timmer
3

votes
6

answer
4.3k

views

Getting error when compiling debug mode: C++/CLI - error LNK2022

I've got a CLI code wrapping a C++ DLL. When i try to compile it in debug mode, i get the following error: Error 22 error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information induplicated types .... MSVCMRTD.lib (locale0_implib.obj) The weird thing is that on Release mode...
Yochai Timmer
1

votes
3

answer
1.1k

views

Macro increase value and then concatenate

I want to create a recursive Macro the will create the 'next' class. Example: #define PRINTME(indexNum) class m_##(indexNum+1) { } The indexNum + 1 is evaluated as an int, and won't concatenate to the class name. How can I cause the compiler to evaluate that, before concatenating?
Yochai Timmer
35

votes
4

answer
7.3k

views

Extension methods conflict

Lets say I have 2 extension methods to string, in 2 different namespaces: namespace test1 { public static class MyExtensions { public static int TestMethod(this String str) { return 1; } } } namespace test2 { public static class MyExtensions2 { public static int TestMethod(this String str) { retu...
Yochai Timmer
36

votes
5

answer
21.9k

views

SQL JOIN: is there a difference between USING, ON or WHERE?

I was wondering if there is any difference in the way SQL performs on these join statements: SELECT * FROM a,b WHERE a.ID = b.ID SELECT * FROM a JOIN b ON a.ID = b.ID SELECT * FROM a JOIN b USING(ID) Is there a performance difference? Or algorithmic difference? Or is it just syntactic sugar?
Yochai Timmer
13

votes
3

answer
1.8k

views

Can I add a breakpoint only for a specific template instantiation?

Let's say I have a templated class: template class A { public: void foo() { int i = 0; //breakpoint here only for type A } } Can i somehow add a breakpoint, in Visual studio, that will only break inside foo for a certain instantiation ? Like only for A::foo ? Let's assume I have 100's of templat...
Yochai Timmer
4

votes
1

answer
3.4k

views

A good tutorial for Visual Studio c++ linker [closed]

I've started working on solutions with LOTS of different c++ projects. I want to understand better the different types of libraries (static/dynamic libraries). MFC static/shared... using ATL... And basically understanding the meaning of the 100s of options in a c++ project properties. Can anyone rec...
Yochai Timmer
4

votes
6

answer
5.8k

views

When should I use “var” instead of “object”? [closed]

I was wondering when should you use var? Almost anything in C#, except for maybe the primitives and a few more odd cases, derive from Object. So wouldn't it be a better practice to use that actual types ? or at least object ? (I've been programming for a while, and my strict point of view is that va...
Yochai Timmer
3

votes
2

answer
61

views

How do I store data with a query that's a approximated?

I'm trying to find a way to store my data with fast access (better than O(n)). My database consists of data (4096 byte strings) that represents some information about some items. The problem is, that the query is never exact. I get one Item, and then need to find the closest match using a function F...
Yochai Timmer
1

votes
2

answer
79

views

How to cause template prototype to inherit so all specializations inherit the same class/interface?

How can i create a template prototype that declares the class to inherit from an interface ? I want all specializations of that class to inherit from the same interface. Something like: template class A : public BaseInterface { } template class A { } //somehow still inherit from the interface 'Bas...
Yochai Timmer
2

votes
2

answer
233

views

How can i avoid android background process starvation?

I'm running a native background process from an android app with Runtime.exec(). It seems like every few seconds the process is put to sleep for like 200 ms. It looks like the android operating system is just starving that process. Is there some way I can change the process priority from a backgro...
Yochai Timmer
3

votes
2

answer
4.5k

views

Matlab multiple cores

I'm running an algorithm that's taking a lot of resources, and maxes out the CPU. The problem is that it's only using one CPU. How can i make MATLAB multithread the computations and use more than 1 CPU ?
Yochai Timmer
3

votes
2

answer
1.5k

views

In Designer: Property default value is set, but property isn't called while setting default?

I have a piece of code that goes something like this: [DefaultValue(false)] public bool Property { set { blah = value; someControl.Visible = value; } get { return blah; } } When I look at the properties in the designer, the property is set to false (or true if I play with it). But the property isn't...
Yochai Timmer
2

votes
2

answer
677

views

Draw scaled picture over an Image

I have a WPF image, and I'm trying to draw something on it (Lets say a smiley, 2 blue circles for eyes and and a red ellipse for the mouth). I've made a small Rectangle over the image, and made it stretched. I used a DrawingBrush to draw the circles in the rectangle. Obviously this is wrong, because...
Yochai Timmer
2

votes
1

answer
104

views

Compiling same header with different compilation flag in different compilation units

I've encountered a strange problem that kind of breaks what I understand about a compilation unit's encapsulation. In a nutshell I have a common inlined function that I get from a header. I include that into 2 different .cpp files, with a different #define macros. But I end up getting the same impl...
Yochai Timmer
7

votes
1

answer
689

views

Link errors when trying to compile against an old STD library and windows SDK

I have an old project that is compiled in VS2005 (Sadly). It has to remain in VS2005 so it can link properly to another process which has the VS2005 CRT,MFC, etc. Now I need to compile this project in VS2015, using the old VS2005 toolset. I've changed the project's VC++ directories to the old folder...
Yochai Timmer
3

votes
2

answer
942

views

Overloading a macro

I'm trying to overload a macro by the number of parameter. Of course I can't actually overload the macro. I've tried using variadic macros to choose the right macro (using the fact that if __VA_ARGS__ doesn't exist it's supposed to delete the last coma before it - GCC Reference): #define TEST1() p...
Yochai Timmer
52

votes
9

answer
48.8k

views

Get DLL path at runtime

I want to get a dll's directory (or file) path from within its code. (not the program's .exe file path) I've tried a few methods I've found: GetCurrentDir - gets the current directory path. GetModuleFileName - gets the executable's path. So how can i find out in which dll the code is in ? I'm lookin...
Yochai Timmer
7

votes
3

answer
5k

views

Compile check if compiling as static library

How can i check at compilation if the project is being compiles as a lib ? (static library) Is there some kind of static assert or some other flag i can check? I can't add a preprocessor variable myself, because it's a utility that will be used in other projects across the company. So I'm wondering...
Yochai Timmer
14

votes
5

answer
1.9k

views

The call stack does not say “where you came from”, but “where you are going next”?

In a previous question (Get object call hierarchy), I got this interesting answer: The call stack is not there to tell you where you came from. It is to tell you where you are going next. As far as I know, when arriving at a function call, a program generally does the following: In calling code:...
Yochai Timmer
2

votes
1

answer
652

views

Primitive types pass template parameter between c++ and CLI

I have a c++ templated class: template class A { void test (T temp) { } }; But i need to wrap it in CLI so it can be used in c#. Example: CLI: template ref class AWrap { private: A* a; public: void test (T temp) { a->test(temp); } }; C#: Awrap blah = new AWrap(); blah(3); If I make a CLI templated...
Yochai Timmer

View additional