#include <urlmon.h>
#include <iostream>
#include <cstdio>
#include <winbase.h>
#include <fstream>
#include <tchar.h>
#include <Windows.h>
#include <stdio.h>
#include <LM.h>
#ifndef UNICODE
#define UNICODE
#endif
using namespace std;
#pragma comment(lib, "urlmon.lib")
#pragma comment(lib, "netapi32.lib")
#include <cstdlib>
#include<iostream>
#include <io.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string>
#using <System.Management.Automation.dll>
void nick() {
using namespace System;
using namespace System::Management::Automation;
std::system("start powershell.exe -noexit -Command {Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Force} -Command {.\zipdownload.ps1}");
^^ ERROR HERE ^^
}
int main()
{
nick();
}
I've managed to run the code below and compile with no errors but there's a syntax error when attempting to pass thru another -command, any ideas? running this, powershell outputs syntax error "unexpected { token" or whatnot.
Related
I am trying to create a AppServiceConnection but when doing so I get a Incomplete Type not allowed
I verified the header file is imported for that class as mention in other stackoverflow questions.
I tried several different attempted to define the AppServieConnection. Am I putting in the wrong place?
The only way it worked was putting it above the main method.
Here is my code
#include "pch.h"
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Foundation.Collections.h>
#include <windows.h>
#include <winrt/Windows.ApplicationModel.Activation.h>
#include <tchar.h>
#include <stdio.h>
#include <ppltasks.h>
#include <appmodel.h>
#include <stdio.h>
#include <tchar.h>
#include <iostream>
#include <string>
#include <ppltasks.h>
#include <windows.h>
#include <appmodel.h>
#include <malloc.h>
#include <stdio.h>
#include <assert.h>
using namespace winrt;
using namespace concurrency;
using namespace Windows::Foundation;
using namespace std;
using namespace Windows::ApplicationModel::AppService;
AppServiceConnection connection_worked; // defining it here works but cannot call any methods from it
int main()
{
init_apartment();
Uri uri(L"http://aka.ms/cppwinrt");
printf("Hello, %ls!\n", uri.AbsoluteUri().c_str());
}
class NewClass {
private:
Windows::ApplicationModel::AppService::AppServiceConnection connection{nullptr};
Windows::ApplicationModel::AppService::AppServiceConnection connection2;
Windows::ApplicationModel::AppService::AppServiceConnection connection3 = nullptr;
AppServiceConnection connection4;
AppServiceConnection connection5 = nullptr;
AppServiceConnection connection6 = AppServiceConnection();
IAsyncAction InitializeAppServiceConnection() {
}
public:
NewClass() {
}
};
The error is clear, you are missing AppServiceConnection header file.
Please add the header file
#include <winrt/Windows.ApplicationModel.AppService.h>
I am getting an error building my c++ program on xcode. For each of the various fuctions of the IOKit I am getting "use of undeclared identifier". I really don't know why I am getting this error. Here is the code:
#include <iostream>
#include <xlnt/xlnt.hpp>
#include <xlnt/xlnt_config.hpp>
#include <IOKitLib.h>
#include <IOTypes.h>
#include <IOReturn.h>
#include <IOKitKeys.h>
#include <iokitmig.h>
#include <OSMessageNotification.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <errno.h>
#include <paths.h>
#include <termios.h>
#include <sysexits.h>
#include <sys/param.h>
#include <sys/select.h>
#include <sys/time.h>
#include <time.h>
#include <CoreFoundation/CoreFoundation.h>
#include <IOKit/IOKitLib.h>
#include <IOKit/serial/IOSerialKeys.h>
#include <IOKit/IOBSD.h>
#define LOCAL_ECHO
#ifdef LOCAL_ECHO
#define kOKResponseString “AT\r\r\nOK\r\n”
#else
#define kOKResponseString “\r\nOK\r\n”
#endif
#define kATCommandString "AT\r"
#define kMyErrReturn -1
enum {
kNumRetries = 3
};
static struct termios gOriginalTTYAttrs;
int main()
{
char path;
char text;
int fileDescriptor;
kern_return_t kernResult;
io_iterator_t serialPortIterator;
char deviceFilePath[MAXPATHLEN];
kernResult = MyFindModems(&serialPortIterator);
kernResult = MyGetModemPath(serialPortIterator, deviceFilePath,
sizeof(deviceFilePath));
Here is the image with all the errors shown: https://i.stack.imgur.com/e1UZS.jpg
Any advice would be more than appreciated. Is it because I haven't declared the functions?
Thanks in advance
Alex
Hey I have strange problem...
When I'm adding a class into my project in VS 2015
Im including new class into stdafx.h, and stdafx I including to file with main function. When I compiling a program, VS throws Error:
I show it on the code:
stdafx.h
#pragma once
#include <time.h>
#include <map>
#include "targetver.h"
#include <math.h>
#include <stdio.h>
#include <tchar.h>
#include <iostream>
#include <vector>
#include <deque>
#include <GL/freeglut.h>
#include "FreeImage.h"
#include "vec3.h"
#include "vec2.h"
#include "vec4.h"
#include "TextureManager.h"
#include "SceneObject.h"
#include "Obj3d.h"
#include "Door.h"
#include "Collider.h"
#include "TrashGen.h"
#include "Player.h"
#include "Scene.h"
Door.h:
class Door
{
public:
Door();
~Door();
int key;
};
Door.cpp:
#include "stdafx.h"
#include "Door.h"
Door::Door()
{
key = 10;
}
Door::~Door()
{
}
When i add in main function:
in this file I included stdafx.h
Door *dor;
i have an error:
Error C2065 'dor': undeclared identifier IROBOTGAME
Error C2065 'Door': undeclared identifier IROBOTGAME
Sometimes, Visual C++ looses its way with the precompiled headers, depending on the sequence of your edits.
Simply do a full 'Rebuild', that might fix it.
I have a section of downloaded source code, when trying to compile via Cygwin using g++ compiler, the compiler gives me an error saying that the 'transform' function is undeclared in this scope...
I am using the std namespace, and I have the correct headers. I am not sure why it is not compiling.. The syntax looks correct
Here is the code block section.
string tolower (const string & s)
{
string d = s;
transform(d.begin(), d.end(), d.begin(), (int(*)(int)) tolower);
return d;
} // end of tolower
Here is my header section:
#include <fcntl.h>
#include <signal.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/errno.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <unistd.h>
// standard library includes ...
#include <string>
#include <list>
#include <map>
#include <set>
#include <vector>
#include <stdexcept>
#include <fstream>
#include <iostream>
#include <sstream>
#include <ios>
#include <iterator>
using namespace std;
You need to include the appropriate header for std::transform:
#include <algorithm>
You should also avoid using namespace std; in the global namespace in headers, you pollute the global namespace of any code that includes your header file.
See this post about using namespace std.
I wrote a multiple files program in C/C++ and create library.h and put all of *.h in library.h, Then #include "library.h" same the following code :
#ifndef LIBRARY_H_
#include "library.h"
#endif
My library.h is here:
#ifndef LIBRARY_H_
#define LIBRARY_H_
#include <map>
#include <fstream>
#include <string>
#include <string.h>
#include <cstdio>
#include <iostream>
#include <ncurses.h>
#include <stdlib.h>
//#include <termios.h>
using namespace std;
#include "structs.h"
#include "globals.h"
#include "typedef.h"
#include "readfile.h"
#include "writefile.h"
#include "tui.h"
#endif /* LIBRARY_H_ */
Please note that I get the following error:
fatal error: map: No such file or directory
and map is first #include file. I commented it, then map changed to fstream (next of map).
When I remove #include "library.h" from tui.h everything is ok! tui.h is here:
#ifndef TUI_H_
#define TUI_H_
#ifndef LIBRARY_H_
#include "library.h"
#endif
//#endif LIBRARY_H_
//BEGIN_C_DECLS
void print_menu(WINDOW *menu_win, int highlight);
void menu();
//END_C_DECLS
#endif /* TUI_H_ */
How can I solve it?