Xcode FLTK
Page 1 of 111 Replies - 459 Views - Last Post: 04 October 2012 - 07:19 PM
#1
Xcode FLTK
Posted 30 September 2012 - 01:36 PM
-lfltk_images
-lfltk_png
-lz
-lfltk_jpeg
-lfltk_forms
-lfltk_gl
-lfltk
-lpthread
I checked for other setting differences between the working project and the new project with Get Info on the projects. The errors are below. From the errors, my guess is that std_lib_facilities class String is being used before #include "std_lib_facilities.h" is reached by the compiler. However, I have included "std_lib_facilities.h" in exactly the same header in both projects. Any tips are appreciated. Thanks.
window.h:17:0 window.h:17: error: 'std::String' has not been declared
window.h:18:0 window.h:18: error: 'std::Vector' has not been declared
Taylor15_5.cpp:68:0 Taylor15_5.cpp:68: warning: unused variable 'n_points'
window.cpp:15: error: prototype for 'Graph_lib::Window2::Window2(int, int, const String&)' does not match any in class 'Graph_lib::Window2'
window.h:27: error: candidates are: Graph_lib::Window2::Window2(const Graph_lib::Window2&)
window.h:32: error: Graph_lib::Window2::Window2(Point, int, int, const std::string&)
window.h:30: error: Graph_lib::Window2::Window2(int, int, const std::string&)
window.cpp:23: error: prototype for 'Graph_lib::Window2::Window2(Point, int, int, const String&)' does not match any in class 'Graph_lib::Window2'
window.cpp:15: error: candidates are: Graph_lib::Window2::Window2(int, int, const String&)
window.h:27: error: Graph_lib::Window2::Window2(const Graph_lib::Window2&)
window.h:32: error: Graph_lib::Window2::Window2(Point, int, int, const std::string&)
window.h:30: error: Graph_lib::Window2::Window2(int, int, const std::string&)
Replies To: Xcode FLTK
#2
Re: Xcode FLTK
Posted 30 September 2012 - 03:04 PM
> window.h:17:0 window.h:17: error: 'std::String' has not been declared
Is windows.h your file? Then the error is in your code.
Next, the issue is std::String. Did you actually type String with a capital S? Because the type is string, not String.
#3
Re: Xcode FLTK
Posted 30 September 2012 - 03:24 PM
#4
Re: Xcode FLTK
Posted 30 September 2012 - 05:45 PM
/*
* Taylor15_5.cpp
* TaylorGraph
*
* Created by nathaniel on 9/19/12.
* Copyright 2012 __MyCompanyName__. All rights reserved.
*
*
* From Stroustrup's Programming: Principles and Practice
* Sectionn 15.5 Approximation, book example
*
* The Taylor approximation gets worse with terms beyond a_13
* due to numerical roundoff error.
*
*/
#include "Taylor15_5.h"
#include "../../std_lib_facilities.h"
#include "Simple_window.h"
#include "Graph.h"
#include "arc.h"
#include <stdio.h>
#include <math.h>
#include <iostream>
using namespace Graph_lib;
int fac(int n) //factorial(n); n!
{
int r=1;
while (n>1){
r*=n;
--n;
}
return r;
}
double term(double x, int n){ return pow(x,n)/fac(n); } //nth term of series
double expe(double x, int n) //sum of n terms for x
{
double sum = 0;
for (int i=0; i<n; ++i) sum+=term(x,i);
return sum;
}
int expN_number_of_terms=10;
double expN(double x)
{
return expe(x,expN_number_of_terms);
}
int main(){
//Global constants
const int xmax=600;
const int ymax=400;
const int x_orig=xmax/2; //position of (0,0) is center of window
const int y_orig=ymax/2;
const Point orig(x_orig,y_orig);
const int r_min=-10; //range [-10:11)
const int r_max=11;
const int n_points = 400; //number of points used in range
const int x_scale = 30; //scaling factors
const int y_scale = 30;
Simple_window win(Point(100,100),xmax,ymax,"Function graphing");
for (int n = 0; n<50; ++n) {
ostringstream ss;
ss<<"exp approximation; n=="<< n;
win.set_label(ss.str().c_str());
expN_number_of_terms = n;
//get next approximation:
Function e(expN,r_min,r_max,orig,200,x_scale,y_scale);
win.attach(e);
win.wait_for_button();
win.detach(e);
}
}
This post has been edited by InterzoneAgent: 30 September 2012 - 05:47 PM
#5
Re: Xcode FLTK
Posted 30 September 2012 - 06:17 PM
That code does not contain any reference to string.
#6
Re: Xcode FLTK
Posted 30 September 2012 - 06:35 PM
That header file was written by Stroustrup (the Creator of C++). Similarly, the other headers and cpp files are written by Stroustrup and I have tested them in another project. I am almost certain the problem is a linking problem. Perhaps this project is reading the source files in a different order than my first project so that the String class is being used before it has been declared or defined. How can I change the order in which the files are ?preprocessed? (not sure if that is the proper term)?
#7
Re: Xcode FLTK
Posted 30 September 2012 - 06:44 PM
#8
Re: Xcode FLTK
Posted 30 September 2012 - 07:35 PM
Is this correct
#include "../../std_lib_facilities.h"
In the other headers such as Graph.h the file is only one directory/folder down.
#include "../std_lib_facilities.h"
It should be ok if there are no warnings.
You could try adding the header to std namespace.
namespace std {
#include "../../std_lib_facilities.h"
}
Apart from that you could create a simpler test program using a string/String variable and std_lib_facilities.h.
This post has been edited by #define: 30 September 2012 - 07:42 PM
#9
Re: Xcode FLTK
Posted 30 September 2012 - 07:43 PM
#include "../../std_lib_facilities.h"
This post has been edited by CTphpnwb: 30 September 2012 - 07:45 PM
#10
Re: Xcode FLTK
Posted 30 September 2012 - 08:15 PM
#11
Re: Xcode FLTK
Posted 01 October 2012 - 06:00 PM
#12
Re: Xcode FLTK
Posted 04 October 2012 - 07:19 PM
|
|

New Topic/Question
Reply



MultiQuote






|