Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
That Turkey Story
Mar 30, 2003

shrughes posted:

Just a heads up, a deque is not necessarily a linked list.

It never is a linked list. A Deque requires constant time random access.

shrughes posted:

Or you can walk two iterators through the vector, a writing iterator and a reading iterator that is always >= the writer.

This would not work since erasing invalidates your iterators (Edit: Oh, nm, I just realized you meant copying as you go, not erasing.

MutantBlue's answer is still most-likely what Dooey wants.

That Turkey Story fucked around with this message at 17:37 on Sep 19, 2010

Adbot
ADBOT LOVES YOU

Dooey
Jun 30, 2009

MutantBlue posted:

Replace that for loop with:
code:
vec.erase(remove_if(vec.begin(), vec.end(), some_condition), vec.end());

Ha Thats even better! I should really learn more about the STL it keeps surprising me with whats it can do.

litghost
May 26, 2004
Builder

MutantBlue posted:

Replace that for loop with:
code:
vec.erase(remove_if(vec.begin(), vec.end(), some_condition), vec.end());

It is worth noting that this still requires copying some elements around. remote_if simple moves the elements to be removed to the back of the vector, and returns the iterator to the first of these elements, basically the order becomes (<good elements>, <bad elements>). Then the erase statement simply reduces the size (but not capacity) of the container to trim the "bad" elements.

Of this is probably what you want, but it is useful to understand what is actually going on. unique works in the same way.

MutantBlue
Jun 8, 2001

litghost posted:

It is worth noting that this still requires copying some elements around. remote_if simple moves the elements to be removed to the back of the vector, and returns the iterator to the first of these elements, basically the order becomes (<good elements>, <bad elements>). Then the erase statement simply reduces the size (but not capacity) of the container to trim the "bad" elements.

Of this is probably what you want, but it is useful to understand what is actually going on. unique works in the same way.

Not exactly. The remove_if performs one pass through the container, moving good elements "left" on top of bad elements without altering the relative order of the remaining elements. It is essentially what shrughes was describing. Otherwise you are correct.

Eggnogium
Jun 1, 2010

Never give an inch! Hnnnghhhhhh!
Ok, this is my first time working with C++ in a while and I thought I had a good understanding of pointers and memory allocation and such but I must be missing something. I have a function that returns a pointer to a struct type, Mesh.

My struct type is defined like so:
code:
struct Mesh
{
  vector<int> m_vi;
  // ... other vectors declared similarly
};
The function looks something like this:

code:
Mesh* plane(...)
{
  Mesh* plane  = new Mesh;

  // ... populate vector objects that make up plane

  return plane;
}
I then call it from another function like so:
code:
Mesh* model = plane(...);
However, all the vector objects in the struct pointed at by model are empty. I've put checks in at the end of plane() and the vectors are properly populated there, and the memory address stored in plane and model is exactly the same. What concept am I missing that's causing this return not to work?

Brecht
Nov 7, 2009

Eggnogium posted:

The function looks something like this:
code:
Mesh* plane(...)
{
  Mesh* plane  = new Mesh;
  // ... populate vector objects that make up plane
  return plane;
}
How, specifically, do you do the population?

Eggnogium
Jun 1, 2010

Never give an inch! Hnnnghhhhhh!

Brecht posted:

How, specifically, do you do the population?

code:
plane->m_vi.push_back(n);

Eggnogium fucked around with this message at 22:38 on Sep 19, 2010

Brecht
Nov 7, 2009
Seems right to me. Here's a small, self-contained example that works:
code:
$ cat mesh.cpp 
#include <iostream>
#include <vector>

struct Mesh
{
    std::vector<int> m_vi;
};

Mesh* plane()
{
    Mesh* plane = new Mesh();
    plane->m_vi.push_back(1);
    plane->m_vi.push_back(2);
    return plane;
}

int main()
{
    Mesh* model = plane();
    for (std::vector<int>::const_iterator it = model->m_vi.begin(); it != model->m_vi.end(); ++it)
    {
        std::cout << *it << std::endl;
    }
    delete model;
    return 0;
}
code:
$ make mesh
g++     mesh.cpp   -o mesh
$ ./mesh
1
2
So maybe just compare what you've got to this?

A MIRACLE
Sep 17, 2007

All right. It's Saturday night; I have no date, a two-liter bottle of Shasta and my all-Rush mix-tape... Let's rock.

I'm a programming noob. Can someone give me a quick tutorial on the difference between i++ and ++i?

shrughes
Oct 11, 2008

(call/cc call/cc)

A MIRACLE posted:

I'm a programming noob. Can someone give me a quick tutorial on the difference between i++ and ++i?

i++ returns the old value of i, and ++i returns the new value of i.

So int i = 3; int j = i++; will make j contain 3, while int i = 3; int j = ++i; will make j contain 4. And i will contain 4 in both cases.

kes
Jan 4, 2006

A MIRACLE posted:

I'm a programming noob. Can someone give me a quick tutorial on the difference between i++ and ++i?

pretend there is no difference and only ever use it on a line by itself

That Turkey Story
Mar 30, 2003

kes posted:

pretend there is no difference and only ever use it on a line by itself

In C++ this can be bad, particularly concerning types that have overloaded ++. Learn the difference and prefer the prefix form when you aren't using the result in an expression since the post-fix semantics often imply having to make a copy that a compiler may not be able to (or be allowed to) optimize away.

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

Just beware of stuff like this:
code:
x = y = 10;

	printf("\n x = %d, y = %d\n x++ = %d, y++ = %d \n", x, y, x++, y--);
Output:
x = 11, y = 9
x++ = 10, y-- = 10

Mr.Radar
Nov 5, 2005

You guys aren't going to believe this, but that guy is our games teacher.

Bob Morales posted:

Just beware of stuff like this:
code:
x = y = 10;

	printf("\n x = %d, y = %d\n x++ = %d, y++ = %d \n", x, y, x++, y--);
Output:
x = 11, y = 9
x++ = 10, y-- = 10


To expand on what Bob Morales is saying, this code has undefined behavior. In C and C++ when you modify the value of an lvalue in an expression, the value of that lvalue is only defined at the next sequence point. In the above code there are three sequence points:
  1. After x and y are assigned.
  2. After the arguments to printf are evaulated but before printf is called.
  3. After printf is called.
Because x is both evaulated and modified between two sequence points, its value is undefined (and similarly for y). Also note that this behavior means there is no defined order that function arguments must be evaluated in. In the case of the compiler Bob Morales used, it appears to evaulate them from right to left, but there's no guarantee of that behavior.

unpurposed
Apr 22, 2008
:dukedog:

Fun Shoe
Hey all, I'm at the end of my wits on a program I'm trying to write and I need help.

Some background: I'm just starting to learn C, but I have lots of experience programming in other languages, so I'm not a complete beginner.


My problem is this: I'm trying to rotate a substring of bits within a bit array by a given amount to either direction. So say I have "10110010" and I want to rotate the substring of bits starting at index 2 (0-indexed from the left) and ending (exclusive) at index 6. If I want to rotate it twice, to the left, then I'd get "10001110". Similarly, if I just want to rotate the entire bit string '1011' 3 times to the right, I'd get "0111".

So I understand the problem and I think I have a way to solve it. Here's the way that the certain structures of the code are implemented:
code:
/* Internal representation of the bit array. */
struct bitarray {
  /* The number of bits represented by this bit array. Need not be divisible by
   * 8. */
  size_t bit_sz;
  /* The underlying memory buffer that stores the bits in packed form (8 per
   * byte). */
  char *buf;
};
and I have some helper methods that I use in my implementation:

code:
/* Portable modulo operation that supports negative dividends. */
static size_t modulo(ssize_t n, size_t m) {
  /* Mod may give different result if divisor is signed. */
  ssize_t sm = (ssize_t) m;
  assert(sm > 0);
  ssize_t ret = ((n % sm) + sm) % sm;
  assert(ret >= 0);
  return (size_t) ret;
}

static char bitmask(size_t bit_index) {
  return 1 << (bit_index % 8);
}
bool bitarray_get(bitarray_t *ba, size_t bit_index) {
  assert(bit_index < ba->bit_sz);
  return (ba->buf[bit_index / 8] & bitmask(bit_index)) ? true : false;
}

void bitarray_set(bitarray_t *ba, size_t bit_index, bool val) {
  assert(bit_index < ba->bit_sz);
  ba->buf[bit_index / 8] = (ba->buf[bit_index / 8] & ~bitmask(bit_index)) | (val ? bitmask(bit_index) : 0); 
}
So the way I implemented my algorithm is the following. My bitarray_rotate method takes a starting index, a length to add to the starting index to determine the substring, and the number of bits to rotate to the right. I just use a reversal algorithm, where I split the bitarray into two, depending on the number of rotations (which I've modulo'd in order to change everything to number of bits to rotate to the left), and I reverse the two parts of the array, and reverse it one more time to get the final answer.

So here's my implementation:

code:
static void arrayReversal(bitarray_t *ba, size_t begin, size_t end){
  bool left, right;
  while(begin < end)
    {
      left = bitarray_get(ba, begin);
      right = bitarray_get(ba, end);
      left ^= right;
      right ^= left;
      left ^= right;                                                   
      bitarray_set(ba, begin, left);
      bitarray_set(ba, end, right);   
      ++begin;
      --end;
    }

}

void bitarray_rotate(bitarray_t *ba, size_t bit_off, size_t bit_len, ssize_t bit_right_amount) {
	assert(bit_off + bit_len <= ba->bit_sz);
	assert(bit_off + bit_len > 0);
	
	if(bit_off + bit_len > ba->bit_sz || bit_off + bit_len < 0) 
		{
			printf("\nError: Indices out of bounds\n");
			return;
		}
	
	/*Find index to split bitarray on*/
	if(bit_len == 0) return; //Rotate only 1 bit i.e. no rotation
	
	size_t reversal_index;
	reversal_index  = modulo(-bit_right_amount, bit_len);
	
	if(reversal_index == 0) return; //No rotation to do

	/*3 bit string reversals*/

	assert(reversal_index - 1 + bit_off < ba->bit_sz);
	/* Reverse A*/
	arrayReversal(ba, bit_off, reversal_index - 1 + bit_off); 

	
	assert(reversal_index + bit_off < ba->bit_sz);
	
	/*Reverse B*/
	arrayReversal(ba, reversal_index + bit_off, (bit_off + bit_len - 1));

	/*Reverse ArBr*/	
	arrayReversal(ba, bit_off, (bit_off + bit_len -1));

	
}
So this works for the test cases that I've tried (namely rotating 10010110 to the left one time, and rotating the substring indexed 2(inclusive) to 5(exclusive) to the right twice.

However, I'm trying to run it on a bitarray that is 98775 bits long, with three rotations done in a row on the entire bitstring. Namely, rotating to the left -98755/4 times (the top number is a size_t, I'm not sure what happens), rotating to the right 98755/4 times and rotating to the right again 98755/2 times.

Now while my code works on the smaller bit strings, it seems to work ~too fast on this big bit string, which leads me to believe it's not working properly.


I've been working on this for about 2 days straight now and I'm mentally exhausted, but it's unfortunately necessary for a project I'm working on.

So where am I going wrong and what can I do to fix it? What cases am I missing out that I'm not testing for, that screws up my algorithm?

So sorry for the super long post, but I'm really in need of some help tonight. Thanks.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
Why are you implementing rotation by using reversals? That seems unnecessarily complex and error-prone for what is actually a pretty simple operation.

Anyway, a rotation by one is trivial to implement by grabbing the bit that will be shifted off the end, moving every other element by one, and then sticking the "stored" bit back on the other end.

A naive implementation will then repeatedly shift-by-one to get the result - it's slow and easily-improved, yes, but the point is that it works, which means that you can use it to easily test your current implementation to see if it's giving correct results. Once you can easily test whether it gives correct results, it's going to much easier to find any bugs.

Also, why are you using that silly xor-swapping technique when you can simply call "set" with the opposite arguments instead?

Dooey
Jun 30, 2009
remove_if seems to be leaving one element in the vector when all the elements in the vector should be removed. I am using MutantBlue's method verbatim. Am I doing something wrong?

Dooey fucked around with this message at 07:03 on Sep 20, 2010

A MIRACLE
Sep 17, 2007

All right. It's Saturday night; I have no date, a two-liter bottle of Shasta and my all-Rush mix-tape... Let's rock.

I'm finishing a lab for data structures and I'm getting this warning:

quote:

warning: passing argument 1 of 'strcpy' makes pointer from integer without a cast
/usr/include/string.h:127: note: expected 'char * __restrict__' but argument is of type 'char'
warning: passing argument 2 of 'strcpy' makes pointer from integer without a cast
/usr/include/string.h:127: note: expected 'const char * __restrict__' but argument is of type 'int'
whenever I pass a 2-d char array like this:

code:
strcpy(rowArray[i][j], tempStr);
Is there a quick fix for this?

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

A MIRACLE posted:

I'm finishing a lab for data structures and I'm getting this warning:

whenever I pass a 2-d char array like this:

code:
strcpy(rowArray[i][j], tempStr);
Is there a quick fix for this?

If you're looking for a "quick fix" instead of trying to understand what's going wrong, you're looking at this problem the wrong way.

First of all, what are you trying to do? I'm guessing it's not "make a copy of a string".

MutantBlue
Jun 8, 2001

Dooey posted:

remove_if seems to be leaving one element in the vector when all the elements in the vector should be removed. I am using MutantBlue's method verbatim. Am I doing something wrong?

What are you using for the unary predicate in remove_if? This may help.

MutantBlue fucked around with this message at 08:09 on Sep 20, 2010

epswing
Nov 4, 2003

Soiled Meat
I want to create an object, passing in a function to be called later.

code:
class MyClass
{
public:
	MyClass(void myDelegate(const string));
	void Run();
	
protected:
	void myDelegate(const string);
}

MyClass::MyClass(void someDelegate(const string))
{
	this->myDelegate = someDelegate;
}

MyClass::Run()
{
	this->myDelegate("epswing");
}
code:
void greet(const string s)
{
	cout << "hello " << s;
}

MyClass c(greet);
c.run();
This gets me

quote:

Error 1 error C2659: '=' : function as left operand
which I believe is telling me that I can't assign something to a member function.

Ok...but if I change the protected member to
code:
void *readDelegate;
I get

quote:

Error 2 error C2064: term does not evaluate to a function taking 1 arguments
and

quote:

Expression must have (pointer-to-) function type
in the Run() function when I try to do this->myDelegate("epswing");

There are lots of examples of passing a function pointer, or about needing to wrap a member function in a non-member function before passing it to the likes of CreateThread, etc, but I can't find or figure out how to hold on to the callback for later use.

epswing fucked around with this message at 18:39 on Sep 20, 2010

Vanadium
Jan 8, 2005

Function pointer type looks like void (*myDelegate)(const string), member function pointer type looks like void (MyClass::*myDelegate)(const string) and needs to be called like (this->*myDelegate)("derp")

epswing
Nov 4, 2003

Soiled Meat
This works. Thanks!

code:
class MyClass
{
public:
	MyClass(void (*myDelegate)(const string));
	void Run();
	
protected:
	void (*myDelegate)(const string);
}

MyClass::MyClass(void (*myDelegate)(const string))
{
	this->myDelegate = someDelegate;
}

MyClass::Run()
{
	this->myDelegate("epswing");
}

epswing fucked around with this message at 19:28 on Sep 20, 2010

Dooey
Jun 30, 2009
I have a class with a member function that returns an object of the same class the function is in, and I want its subclasses to return an object of the subclass. Can I do that? Example:

code:
class A {
    A();
    ??? func();
};

class B : public A {
    B();
};

A a1 = A();
B b1 = B();

A a2 = A.func();
B b2 = B.func();
What, if anything, can I do to achieve this?

That Turkey Story
Mar 30, 2003

Dooey posted:

I have a class with a member function that returns an object of the same class the function is in, and I want its subclasses to return an object of the subclass. Can I do that? Example:

code:
class A {
    A();
    ??? func();
};

class B : public A {
    B();
};

A a1 = A();
B b1 = B();

A a2 = A.func();
B b2 = B.func();
What, if anything, can I do to achieve this?

You'll have to give a little bit more information since there are different answers depending on your situation. If the example is exactly like what you have shown and you don't want to have to explicitly duplicate code then you need to use templates (or macros if you really wanted). If you want to call the member function from a pointer or reference to the base and have it return an instance of the child then you need to also change your function to return a pointer or reference as opposed to the object directly.

A solution to the exact situation you have shown could be:

code:
template< typename ChildType >
struct func_helper
{
  ChildType func();
};

class A
  : func_helper< A >
{
public:
  using func_helper< A >::func;
};

class B
  : func_helper< B >, public A 
{
public:
  using func_helper< B >::func;
};
It gets a tiny bit more complicated if you need virtual function behavior on top of this (such as for an auto-implemented clone), but still not bad.

Dooey
Jun 30, 2009
The example is almost exactly the situation I have, so I'll give your suggestion a shot. Thanks, I never would have thought of that myself.

Dooey
Jun 30, 2009
OK, its not quite the same as the example because func() is a template function, and A is also a subclass of something else. Which is a template class. I figured I could do something like this:

code:
template<typename ChildType>
struct func_helper {
    template<typename T>
    ChildType func(T t);
};

template<typename T>
class A_super {
};

template<typename T>
class A : public A_super<T>, public func_helper<A<T>> {
public:
    using func_helper<A<T>>::func<T>; //Error C2873 and C2244 here!
};

class B : public func_helper<B>, public A<int> {
public:
    using func_helper<B>::func<int>;
};
This is exactly my situation, the only different being that func() takes some more (non-template) parameters, and I don't inherit from public A<int> in B, I use a type of my own in place of int.

The error I am getting is error C2873: 'func_helper<ChildType>::Subset' : symbol cannot be used in a using-declaration and error C2244: 'func_helper<ChildType>::func' : unable to match function definition to an existing declaration
definition
'ChildType func_helper::func(T)'
existing declarations
'ChildType func_helper<ChildType>::func(T)'

Help please?

That Turkey Story
Mar 30, 2003

Dooey posted:

OK, its not quite the same as the example because func() is a template function, and A is also a subclass of something else. Which is a template class. I figured I could do something like this:

code:
template<typename ChildType>
struct func_helper {
    template<typename T>
    ChildType func(T t);
};

template<typename T>
class A_super {
};

template<typename T>
class A : public A_super<T>, public func_helper<A<T>> {
public:
    using func_helper<A<T>>::func<T>; //Error C2873 and C2244 here!
};

class B : public func_helper<B>, public A<int> {
public:
    using func_helper<B>::func<int>;
};
This is exactly my situation, the only different being that func() takes some more (non-template) parameters, and I don't inherit from public A<int> in B, I use a type of my own in place of int.

The error I am getting is error C2873: 'func_helper<ChildType>::Subset' : symbol cannot be used in a using-declaration and error C2244: 'func_helper<ChildType>::func' : unable to match function definition to an existing declaration
definition
'ChildType func_helper::func(T)'
existing declarations
'ChildType func_helper<ChildType>::func(T)'

Help please?

Just change those to using func_helper< A < T > >::func; and using func_helper< B >::func; You can't pull in specific instantiations of the function template with using, only the entire template.

Also, in the example I gave earlier I made the func_helper bases private on purpose, but you made them public here. It won't affect execution, but you should try to keep any helper bases like that private as they are implementation details that users should not be able to work with directly.

Dooey
Jun 30, 2009
Alright thanks.

LP0 ON FIRE
Jan 25, 2006

beep boop
I have some confusion about memory locations in C. Still new to this. If I do something like this, I can go to different slices by doing foo++.

code:
foo = malloc ( sizeof(int) * 10);

int *fooStart;
fooStart = foo;

*foo = 5;
foo++;
*foo = 7394;

free (fooStart);
So instead, I'd like to pick out a specific memory location instead of just using++. I know I could do foo+=2 to get the third slice, but I'd want it to pick out a slice relative to first slice always. I wish I could just do foo=2 to get to the third slice.

Vanadium
Jan 8, 2005

Like foo = fooStart + 2;?

LP0 ON FIRE
Jan 25, 2006

beep boop
Yeah I thought I did that but I had problems. I'll try again but it's good to know that's the solution! Thanks!

edit: Very simple example from a book that I edited just a bit. How the heck does it know that the main's 2nd argument is going to be a keyboard input value? I'm not having any problem with the code. I just don't know how it KNOWS this. I'm using OS X's terminal. The book doesn't go on to explain it.

I'm using the command. ./AddressBook example1 example2

code:
#include <stdio.h>

main ( int inputCount, char *inputValues[] ){

	int nameCount = (inputCount - 1);
	
	if (nameCount > 0 & nameCount < 10) {
		printf ( "You entered %i names \n", nameCount );
	}else if (nameCount >= 10 ) {
		printf ( "You entered %i names. Wow, that's a lot. \n", nameCount );
	}else{
		printf ( "You didn't enter any names.\n");
	}

	char *formattedNames[ nameCount ];

	int i;

	for ( i = 0; i < nameCount; i++ ){

		char *currentName = inputValues[i+1];
		asprintf ( &formattedNames[i], "Name %i: %s", i, currentName );
	}

	for (i=0; i<nameCount; i++){
		printf("%s \n", formattedNames[i]);
	}

	for (i=0; i<nameCount; i++){
		free(formattedNames[i]);
	}
}

LP0 ON FIRE fucked around with this message at 21:18 on Sep 22, 2010

DeciusMagnus
Mar 16, 2004

Seven times five
They were livin' creatures
Watch 'em come to life
Right before your eyes
main is passed the arguments you type in with your keyboard on the command line (or launched from a script, etc). That's just what C does for main, don't worry too much about it for now. Just know that the first element in argv (argv[0]) is the name the program was invoked with (you can ignore this for now) and the following elements are the following arguments.

The addressing you want to do, as mentioned in your other post, is with the [] operator: foo[2] provides access to the third element of the array or the second offset from the beginning.

Grazing Occultation
Aug 18, 2009

by angerbutt
We've got a legacy program in C, currently built under VS2008 using the C compiler. It's composed of several DLLs. It's not particularly well written but it works...mostly.

The issue I'm having is that every now and then a call like atan(0.7) will return -1#.IND0. It's not always atan/atan2 that fails, but it seems to always be math.h functions. This is in a trig heavy program; it does a lot of navigation-related geometry and this failure only happens exceptionally rarely. So rarely, in fact, that we can't work out when it started.

I've checked for memory corruption using _CRTDBG_CHECK_ALWAYS_DF because when I have a problem this odd it's usually something along those lines. I've also tested for memory leaks. That ruled out corruption from dynamically allocated memory and there aren't many statically allocated arrays.

Anyone got any ideas?

Mr.Radar
Nov 5, 2005

You guys aren't going to believe this, but that guy is our games teacher.
Does the bug happen on different systems? Maybe one of the CPU cores it's running on has a slightly defective floating point unit which works 99.99999% of the time, but fails that other 0.00001% or maybe you have some bad RAM. Both would account for the rare and intermittent nature of the bug.

Grazing Occultation
Aug 18, 2009

by angerbutt

Mr.Radar posted:

Does the bug happen on different systems? Maybe one of the CPU cores it's running on has a slightly defective floating point unit which works 99.99999% of the time, but fails that other 0.00001% or maybe you have some bad RAM. Both would account for the rare and intermittent nature of the bug.

It's happening on different machines - we've had it on machines running XP, Vista, and 7. It's not always happening in the same place though.

DeciusMagnus
Mar 16, 2004

Seven times five
They were livin' creatures
Watch 'em come to life
Right before your eyes

Grazing Occultation posted:

Anyone got any ideas?

I've got a couple things that come to mind immediately. Are any of the libraries you're linking in overriding MSVC's libraries? Perhaps one that isn't written very well. If so, and assuming you need this overriding, can you verify the code for this particular atan is correct? Was it compiled with the optimizations all the way up? Optimization bugs occasionally crop up and are a pain because they are more difficult to debug in a debugger.

Grazing Occultation
Aug 18, 2009

by angerbutt

DeciusMagnus posted:

I've got a couple things that come to mind immediately. Are any of the libraries you're linking in overriding MSVC's libraries? Perhaps one that isn't written very well. If so, and assuming you need this overriding, can you verify the code for this particular atan is correct? Was it compiled with the optimizations all the way up? Optimization bugs occasionally crop up and are a pain because they are more difficult to debug in a debugger.

Nope. No one I work with is that clever/prone to shooting themselves in the foot. I think I'm the only one who knows how the compiler options even work!

lemonadesweetheart
May 27, 2010

It's pretty hard to determine what the problem is without the source. I know you said you tested for dynamic allocations so the only other place I can thing of is have you checked the type conversions, floats are tricky bitches. Also make sure that the type definitions are correct for the platforms you're using them on.

Adbot
ADBOT LOVES YOU

ctz
Feb 6, 2003
Do you have any code or libraries which are using mmx/sse* functions without issuing emms?

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply