Техническая Спецификация для Microchip Technology SW006023-2N

Скачать
Страница из 238
MPLAB
®
 XC32 C/C++ Compiler User’s Guide
DS51686E-page 52
 2012 Microchip Technology Inc.
The following is a simple C++ program. Create the following program with any 
plain-text editor and save it as ex2.cpp.
/* ex2.cpp */
#include <xc.h>     // __XC_UART
#include <plib.h>   // SYSTEMConfigPerformance()
#include <iostream>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <iterator>
#include <functional>
#include <numeric>
using namespace std;
// Device-Specific Configuration-bit settings
#pragma config FPLLMUL=MUL_20, FPLLIDIV=DIV_2, FPLLODIV=DIV_1, 
FWDTEN=OFF
#pragma config POSCMOD=HS, FNOSC=PRIPLL, FPBDIV=DIV_8
template <class T>
inline void print_elements (const T& coll, const char* optcstr="")
{
    typename T::const_iterator pos;
    std::cout << optcstr;
    for (pos=coll.begin(); pos!=coll.end(); ++pos) {
        std::cout << *pos << ' ';
    }
    std::cout << std::endl;
}
template <class T>
inline void insert_elements (T& coll, int first, int last)
{
    for (int i=first; i<=last; ++i)
    {
        coll.insert(coll.end(),i);
    }
}
int main(void) {
    
    // Configure the target for max performance at 80 MHz.
    SYSTEMConfigPerformance (80000000UL);
    
    // Direct stdout to UART 1 for use with the simulator
    __XC_UART = 1;
    deque<int> coll;
    insert_elements(coll,1,9);
    insert_elements(coll,1,9);
    print_elements(coll, "on entry: ");