Note that there are some explanatory texts on larger screens.

plurals
  1. POexpected unqualified-id before string constant
    primarykey
    data
    text
    <p>I'm currently writing a C++ application which implements an Oscillator in conjuction with math.h. The code I have should work fine for the application (trying to compile an object file), bu I'm getting a compiler error most likely having to do with syntax/etc; I think it has something to do with namespace. The error:</p> <p>Terminal Output:</p> <pre><code>User-Name-Macbook-Pro:Synth Parts UserName$ make g++ -o Oscillators.o -c -I. Oscillators.cpp -c In file included from Oscillators.cpp:2: /usr/include/math.h:41: error: expected unqualified-id before string constant In file included from /usr/include/c++/4.2.1/bits/locale_facets.tcc:42, from /usr/include/c++/4.2.1/locale:46, from /usr/include/c++/4.2.1/bits/ostream.tcc:46, from /usr/include/c++/4.2.1/ostream:635, from /usr/include/c++/4.2.1/iostream:45, from Oscillators.cpp:4: /usr/include/c++/4.2.1/typeinfo:41: error: expected declaration before end of line make: *** [Oscillators.o] Error 1 </code></pre> <p>Oscillators.cpp</p> <pre><code>#include "Oscillators.h" #include &lt;math.h&gt; #include &lt;vector&gt; #include &lt;iostream&gt; #define TWOPI (6.2831853072) using namespace std; oscillator(int srate = 44100, int tabsize = 8192, double freq = 200) // Default to output 200Hz Sine Wave { if(srate &lt;= 0) { cout &lt;&lt; "Error: sample rate must be positive" &lt;&lt; endl; return; } sizeovrsr_ = (double)tabsize / (double)srate if(freq &lt; 20 || freq &gt; 20000) { cout &lt;&lt; "Error: frequency is out of audible range" &lt;&lt; endl; return; } curfreq_ = freq; curphase_ = 0.0 // Not out of one, out of tabsize incr_ = curfreq * sizeovrsr_; for(int i = 0; i &lt; tabsize; i++) { gtable.push_back(sin((i*TWOPI)/(double)tabsize)); } gtable.push_back(gtable[0]); } void print_table() { vector&lt;double&gt;::size_type i; for(i = 0; i &lt; gtable.size(); i++) cout &lt;&lt; gtable[i] &lt;&lt; "\n"; cout &lt;&lt; endl; } </code></pre> <p>Oscillators.h</p> <pre><code>#ifndef GUARD_OSCILLATORS_H #define GUARD_OSCILLATORS_H #include &lt;vector&gt; class oscillator { public: /* void fill_sine(); // Will change the table to a sine wave void fill_square(); // Will change the table to a square wave void fill_sawtooth(); // Will change the table to a sawtooth wave void fill_triangle(); // Will change the table to a triangle wave double tick(double freq); // Will output the current sample and update the phase */ void print_table(); // Will print all table values to standard output oscillator(int srate = 44100, double freq = 200, int tabsize = 8192); private: double sizeovrsr_; // Will be set at initialization and will determine phase increase for tick func double curphase_; double curfreq_; // if the freq sent to a tick function doesn't match the current tick, it will be reset; double incr_; std::vector&lt;double&gt; gtable_; // Will contain a wavetable with a guard point. } #endif </code></pre> <p>I've seen other suggestions that mention using g++ -Wall -g but I'm not sure that that is the problem, and that there is something else going on here.</p> <p>Any help would be much appreciated! Thanks!!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload